FlorianREGAZ / Python-Tls-Client

Advanced HTTP Library
MIT License
626 stars 130 forks source link

add multipart/form-data #69

Open phgas opened 1 year ago

phgas commented 1 year ago

with requests it's:

payload={'key_1': 'one','key_2': '2'}
response = requests.post(url, data=payload, files=[])

EDIT: possibility to change boundary in header/payload is recommended see https://stackoverflow.com/questions/12385179/how-to-send-a-multipart-form-data-with-requests-in-python

phgas commented 1 year ago

Semi-beautiful Solution:

from requests_toolbelt.multipart.encoder import MultipartEncoder

mp_encoder = MultipartEncoder(
    fields={
        'foo': 'bar'
    }
)

mp_encoder.to_string()
mp_encoder.content_type
adiazma commented 5 months ago

Were you able to do it?

OculusVisionSellix commented 4 weeks ago

As @phgas already mentioned: Check this #93

You need to submit data = your_multipart_encoded_object.to_string().decode('utf-8')