Tuesday, 16 October 2018

OS dependent behavior of requests post

When I run the same python code:

url = ''  # this is normally populated but don't want to post it here
file_to_send = {'filename': (filename, open(filename, 'rb'))}
r = requests.post(url, files=file_to_send)
print(r.text)

I get different results dependent on OS. In macOS and Linux, the r.text is:

<html><head><title>MinXSS HAM Radio Beacon Upload</title></head><body>
<form method='post' action='fileupload.php' enctype='multipart/form-data'[>
Select File: <input type='file' name='filename' size='10' />
<input type='submit' value='Upload' />
</form><br/>Uploaded file '2018-10-13T14_35_30.371095_SFJPM86_40.241_-105.2353.dat'<br/></body></html>

but on Windows it's:

"<html><head><title>MinXSS HAM Radio Beacon Upload</title></head><body>\n<form method='post' action='fileupload.php' enctype='multipart/form-data'[>\nSelect File: <input type='file' name='filename' size='10' />\n<input type='submit' value='Upload' /></form></body></html>"

When I check the server, the files do actually successfully upload for macOS and Linux but not for Windows.



from OS dependent behavior of requests post

No comments:

Post a Comment