Skip to content

Encode HTTP request header string components as (ASCII) bytes. #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 11, 2019
Merged

Encode HTTP request header string components as (ASCII) bytes. #25

merged 1 commit into from
Mar 11, 2019

Conversation

anecdata
Copy link
Member

@anecdata anecdata commented Mar 9, 2019

Client app code (previously crashed with TypeError: can't convert str to int in line 176), e.g.:

custom_headers = {"X-Moose" : "Bullwinkle",  "X-Squirrel" : "Rocky", }
response = wifi.get("https://example.com/", data=None, json=None, headers=custom_headers, stream=False)

Now results in request headers received by the remote server, e.g.:

HTTP_X_MOOSE: Bullwinkle
HTTP_X_SQUIRREL: Rocky

(Note: headers are case-insensitive and capitalization varies between server environments.)

@ladyada
Copy link
Member

ladyada commented Mar 9, 2019

not surprising - i never tested that stuff - but @brentru may have!

@brentru
Copy link
Member

brentru commented Mar 11, 2019

I didn't use custom headers like this originally as I ran into the same issue - was encoding the string from the client's init. Don't have to do that anymore though! Tested this PR on a PyPortal with a modified Adafruit IO CircuitPython library - and it's working with examples using post/get.

@brentru brentru merged commit 74eaea9 into adafruit:master Mar 11, 2019
@anecdata anecdata deleted the fix_optional_request_headers branch March 11, 2019 17:13
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Mar 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants