adafruit / Adafruit_CircuitPython_Requests

Requests-like interface for web interfacing
MIT License
51 stars 37 forks source link

Refactor request method to use parse_headers #7

Closed brentru closed 5 years ago

brentru commented 5 years ago

Addressing https://github.com/adafruit/Adafruit_CircuitPython_Requests/issues/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 commented 5 years ago

@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
brentru commented 5 years ago

@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