Closed GC-RnD closed 1 year ago
From the readme:
save_headers
(bool) - a boolean, which is passed to the constructor of the response class instance, which determines whether it keeps a reference to the response headers in the instance. This is set toFalse
by default to save memory. If set toTrue
, the default response class will make the reponse header lines available via itsheaders
instance attribute as a list of unparsed bytes objects.
This only works in mrequests, not urequests.
Christopher That Worked !! I so sorry, my eyes are popping out of my face with so much Googling. THANK YOU SO MUCH !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Rich Golden
From: Christopher Arndt @.> Sent: Monday, October 24, 2022 3:50 PM To: SpotlightKid/mrequests @.> Cc: Rich Golden @.>; Author @.> Subject: Re: [SpotlightKid/mrequests] Not able to get responce headers (Issue #7)
From the readme:
save_headers (bool) - a boolean, which is passed to the constructor of the response class instance, which determines whether it keeps a reference to the response headers in the instance. This is set to False by default to save memory. If set to True, the default response class will make the reponse header lines available via its headers instance attribute as a list of unparsed bytes objects.
— Reply to this email directly, view it on GitHubhttps://github.com/SpotlightKid/mrequests/issues/7#issuecomment-1289521381, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AEJ4GXZJ4QIHBVT3QBLRKLTWE3R7HANCNFSM6AAAAAARNIZOSY. You are receiving this because you authored the thread.Message ID: @.***>
See also this example: https://github.com/SpotlightKid/mrequests/blob/master/examples/parse_response_headers.py
Hi Christopher, Got some problems…
If I use mrequests… and use {"Authorization": "Bearer"} I get a Warning: Comparison between bytes and str but not in urequests also data=payload returns null… but not in urequests.
Again am I overlooking something ???
import mrequests as requests import ujson headersList = {"Authorization": "Bearer"} payload = ujson.dumps({ "msg": "Can you here me now ???" }) r = requests.get("http://httpbin.org/anything", headers=headersList, data=payload) print(r.text) r.close()
Warning: Comparison between bytes and str { "args": {}, "data": "", "files": {}, "form": {}, "headers": { "Authorization": "Bearer", "Host": "httpbin.org", "X-Amzn-Trace-Id": "Root=1-63593988-4a3ac2c4683689f761abb814" }, "json": null, "method": "GET", "origin": "69.116.162.165", "url": "http://httpbin.org/anything" }
import urequests as requests import ujson headersList = {"Authorization": "Bearer"} payload = ujson.dumps({ "msg": "Can you here me now ???" }) r = requests.get("http://httpbin.org/anything", headers=headersList, data=payload) print(r.text) r.close()
{ "args": {}, "data": "{\"msg\": \"Can you here me now ???\"}", "files": {}, "form": {}, "headers": { "Authorization": "Bearer", "Content-Length": "34", "Host": "httpbin.org", "X-Amzn-Trace-Id": "Root=1-635938f6-46f8d2aa296c76da5db19b44" }, "json": { "msg": "Can you here me now ???" }, "method": "GET", "origin": "69.116.162.165", "url": "http://httpbin.org/anything" }
Thanks Rich
From: Christopher Arndt @.> Sent: Monday, October 24, 2022 4:09 PM To: SpotlightKid/mrequests @.> Cc: Rich Golden @.>; Author @.> Subject: Re: [SpotlightKid/mrequests] Not able to get responce headers (Issue #7)
See also this example: https://github.com/SpotlightKid/mrequests/blob/master/examples/parse_response_headers.py
— Reply to this email directly, view it on GitHubhttps://github.com/SpotlightKid/mrequests/issues/7#issuecomment-1289543729, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AEJ4GX7YY7LCF7JANOEZKC3WE3UERANCNFSM6AAAAAARNIZOSY. You are receiving this because you authored the thread.Message ID: @.**@.>>
Pass in everything (URL, header keys and values, as bytes
not str
, and the warning should go away. It's just a warning, though, and should still work. See also #3.
As for data
. You can't send request data with a GET
request with mrequests
. Doing that makes no sense in HTTP. Use a POST
request. The fact that it works with urequests
is due to the fact that httpbin.org
runs an HTTP server specifically made for testing, so it doesn't always act according to standards.)
Also, please open new issues for new problems.
Hi Christopher,
This problem of mine is defined at micropython forum... https://github.com/orgs/micropython/discussions/9733
Your help would be much appreciated !!!! Thank You