requests
requests copied to clipboard
Help defeat requests. Only urllib3 works.
trafficstars
pcapng.zip [Please refer to our Stack Overflow tag for guidance.](https://stackoverflow.com/questions/75147860/post-request-to-send-file-file-fw-not-working) Good afternoon! I have been unable to make a working POST request to send the firmware for many months now. Works only through urllib3:
import urllib3
http = urllib3.PoolManager()
ip="10.254.255.105"
name_file="boot_v1.5_app_v2.27.8.fw"
uri = "/firmware/update_from_page.htm"
with open(name_file, 'rb') as fp:
file_data = fp.read()
send = http.request(
'POST',
'http://' + ip + uri,
fields={'new_firmware': (name_file, file_data),}
)`
Problem line for the requests library:
send = requests.post(
url='http://'+ip+uri,
data={'new_firmware': (name_file, file_data),},
)
Tried using it in different ways:
- using sessions
- Adding headers, including from the working request urllib3
- Adding various parameters verify = False, allow_redirects=True\False
- Changing data= to files= resets the connection I also did Wireshark dumps, maybe this will help determine the differences in requests. At first glance, they differ in size (requests are twice as large)
When using the requests library, the process does not stop, the connection is not interrupted. Only after the script is forced to stop, the device restores availability.
Did you try to open the file before sending the POST request ? like this:
import requests
url = '<your url>'
yourfiles = {'file': open('<name off file>' ,'rb')}
#You can also add a timeout parameter
send= requests.post(url, files = myfiles,timeout=5)