realgam3 / requests-raw

Use requests to send HTTP raw sockets (To Test RFC Compliance)
Apache License 2.0
19 stars 1 forks source link

Hello, How can I read a non-standard response #5

Closed cyal1 closed 8 months ago

cyal1 commented 1 year ago

Hello, How can I read a non-standard response

realgam3 commented 1 year ago

Do you have an example πŸ˜…? I want to be sure it’s not something that will be easier to use raw sockets

On Tue, 18 Oct 2022 at 3:47 cyal1 @.***> wrote:

Hello, How can I read a non-standard response

β€” Reply to this email directly, view it on GitHub https://github.com/realgam3/requests-raw/issues/5, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABKOSGGQDUPDRHJ4YSZKTWTWDXXT5ANCNFSM6AAAAAARHSPOB4 . You are receiving this because you are subscribed to this thread.Message ID: @.***>

dem0ns commented 1 year ago

I got the same problem, i want to get raw response but an exception throwed

realgam3 commented 1 year ago

I got the same problem, i want to get raw response but an exception throwed

Can you add the request and the exception + stacktrace so I can find a solution for it?

dem0ns commented 1 year ago

run this command to fake a response:

echo 'HTTP/1.1 1x OK
Server: xxx
Content-Length: 6

011110' | nc -l 123

Code

import requests_raw

if __name__ == '__main__':
        x = requests_raw.raw("http://127.0.0.1:123", "GET / HTTP/1.1\r\n\r\n")

Exception: ('Connection aborted.', BadStatusLine('HTTP/1.1 1x OK\n'))

Traceback:

Traceback (most recent call last):
  File "/opt/homebrew/lib/python3.10/site-packages/urllib3/connectionpool.py", line 703, in urlopen
    httplib_response = self._make_request(
  File "/opt/homebrew/lib/python3.10/site-packages/urllib3/connectionpool.py", line 449, in _make_request
    six.raise_from(e, None)
  File "<string>", line 3, in raise_from
  File "/opt/homebrew/lib/python3.10/site-packages/urllib3/connectionpool.py", line 444, in _make_request
    httplib_response = conn.getresponse()
  File "/opt/homebrew/Cellar/python@3.10/3.10.9/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 1374, in getresponse
    response.begin()
  File "/opt/homebrew/Cellar/python@3.10/3.10.9/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 318, in begin
    version, status, reason = self._read_status()
  File "/opt/homebrew/Cellar/python@3.10/3.10.9/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 308, in _read_status
    raise BadStatusLine(line)
http.client.BadStatusLine: HTTP/1.1 1x OK
realgam3 commented 1 year ago

Oh so this is actually an issue with httplib but I think o can fix it πŸ˜… 1x is the actual response code? Or 100/101?

On Tue, 10 Jan 2023 at 15:30 Dem0ns @.***> wrote:

run this command to fake a response:

echo 'HTTP/1.1 1x OK Server: xxx Content-Length: 6

011110' | nc -l 123

Code

import requests_raw

if name == 'main': x = requests_raw.raw("http://127.0.0.1:123", "GET / HTTP/1.1\r\n\r\n")

Exception: ('Connection aborted.', BadStatusLine('HTTP/1.1 1x OK\n'))

Traceback:

Traceback (most recent call last): File "/opt/homebrew/lib/python3.10/site-packages/urllib3/connectionpool.py", line 703, in urlopen httplib_response = self._make_request( File "/opt/homebrew/lib/python3.10/site-packages/urllib3/connectionpool.py", line 449, in _make_request six.raise_from(e, None) File "", line 3, in raise_from File "/opt/homebrew/lib/python3.10/site-packages/urllib3/connectionpool.py", line 444, in _make_request httplib_response = conn.getresponse() File @./3.10.9/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 1374, in getresponse response.begin() File @./3.10.9/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 318, in begin version, status, reason = self._read_status() File @.***/3.10.9/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 308, in _read_status raise BadStatusLine(line) http.client.BadStatusLine: HTTP/1.1 1x OK

β€” Reply to this email directly, view it on GitHub https://github.com/realgam3/requests-raw/issues/5#issuecomment-1377278371, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABKOSGBRCX7N2L3OPATGG4DWRVP5ZANCNFSM6AAAAAARHSPOB4 . You are receiving this because you commented.Message ID: @.***>

realgam3 commented 1 year ago

Please try: https://github.com/realgam3/requests-raw/tree/v1.1 :)

realgam3 commented 8 months ago

Version 2.0.0 Released: https://github.com/realgam3/requests-raw/releases/tag/v2.0.0