Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Refactor request method to use parse_headers #7

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 4 commits into from
Aug 2, 2019

Conversation

brentru
Copy link
Member

@brentru brentru commented Aug 1, 2019

Addressing #6

Request now uses parse_headers.

Tested with WSGIServer.py on Adafruit CircuitPython 4.0.0 on 2019-05-20; Adafruit PyPortal with samd51j20.
https://github.com/adafruit/Adafruit_CircuitPython_ESP32SPI/blob/master/examples/server/esp32spi_wsgiserver.py

@brentru brentru requested a review from a team August 1, 2019 14:44
@brentru
Copy link
Member Author

brentru commented Aug 2, 2019

@mscosti Thanks for the review, made requested changes (modified them a bit to work properly).


Test transfer-encoding

Fetching text from https://http-evader.semantic-gap.de/-BNBbebyzMwzSuz4dk7UyGt2idQ3EpHQa1KU1Etm0dzHohAtWjf5p
Traceback (most recent call last):
  File "code.py", line 39, in <module>
  File "/lib/adafruit_requests.py", line 270, in get
  File "/lib/adafruit_requests.py", line 236, in request
  File "/lib/adafruit_requests.py", line 230, in request
ValueError: Unsupported b'HTTP/1.2'

Test HTTP Transfer Requests:

Fetching text from https://jigsaw.w3.org/HTTP/300/301.html
Traceback (most recent call last):
  File "code.py", line 39, in <module>
  File "/lib/adafruit_requests.py", line 270, in get
  File "/lib/adafruit_requests.py", line 236, in request
  File "/lib/adafruit_requests.py", line 232, in request
NotImplementedError: Redirects not yet supported

resp.headers = parse_headers(sock)
if resp.headers.get("transfer-encoding"):
if "chunked" in resp.headers.get("transfer-encoding"):
raise ValueError("Unsupported " + str(line[0]))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, missed this one on my first pass. I think this is supposed to be the transfer encoding header value in the exception string.

@brentru
Copy link
Member Author

brentru commented Aug 2, 2019

@mscosti Moved the header value into the exception string...

Fetching text from https://http-evader.semantic-gap.de/-BNBbebyzMwzSuz4dk7UyGt2idQ3EpHQa1KU1Etm0dzHohAtWjf5p
Traceback (most recent call last):
  File "code.py", line 39, in <module>
  File "/lib/adafruit_requests.py", line 270, in get
  File "/lib/adafruit_requests.py", line 236, in request
  File "/lib/adafruit_requests.py", line 230, in request
ValueError: Unsupported chunked

Copy link

@mscosti mscosti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@brentru brentru merged commit 59a467e into adafruit:master Aug 2, 2019
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Aug 2, 2019
Updating https://github.com/adafruit/Adafruit_CircuitPython_ILI9341 to 1.0.4 from 1.0.3:
  > Merge pull request adafruit/Adafruit_CircuitPython_ILI9341#11 from makermelissa/master
  > Merge pull request adafruit/Adafruit_CircuitPython_ILI9341#10 from makermelissa/master
  > Merge pull request adafruit/Adafruit_CircuitPython_ILI9341#9 from makermelissa/master

Updating https://github.com/adafruit/Adafruit_CircuitPython_Requests to v1.1.0 from v1.0.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_Requests#7 from brentru/refactor_req
  > Merge pull request adafruit/Adafruit_CircuitPython_Requests#5 from brentru/add-parse-headers
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.

2 participants