Closed Ovi3 closed 3 years ago
Thank you for the information, Issue reproduced, I will fix it as soon as possible :)
I think I found the root cause: You can remove: "Accept-Encoding: gzip, deflate" for now and it should work fine...
@realgam3 i have same error.. but i am not using Accept-Encoding????
res = requests_raw.raw(url="https://www.google.com", data=b"GET /?ani=asas HTTP/1.1\r\nHost: www.google.com\r\nUser-Agent: Mozilla Firefox 55/66\r\n\r\n")
www.google.com\r\nUser-Agent: Mozilla Firefox 55/66\r\n\r\n")
Traceback (most recent call last):
File "<pyshell#52>", line 1, in <module>
res = requests_raw.raw(url="https://www.google.com",data="GET /?ani=<cyberthereaper> HTTP/1.1\r\nHost: www.google.com\r\nUser-Agent: Mozilla Firefox 55/66\r\n\r\n")
File "C:\Users\Levent\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\requests_raw\api.py", line 7, in raw
return session.request(__title__, url, data=data, **kwargs)
File "C:\Users\Levent\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\requests\sessions.py", line 542, in request
resp = self.send(prep, **send_kwargs)
File "C:\Users\Levent\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\requests\sessions.py", line 697, in send
r.content
File "C:\Users\Levent\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\requests\models.py", line 831, in content
self._content = b''.join(self.iter_content(CONTENT_CHUNK_SIZE)) or b''
File "C:\Users\Levent\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\requests\models.py", line 753, in generate
for chunk in self.raw.stream(chunk_size, decode_content=True):
File "C:\Users\Levent\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\urllib3\response.py", line 572, in stream
for line in self.read_chunked(amt, decode_content=decode_content):
File "C:\Users\Levent\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\urllib3\response.py", line 754, in read_chunked
if self._original_response and is_response_to_head(self._original_response):
File "C:\Users\Levent\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\urllib3\util\response.py", line 107, in is_response_to_head
return method.upper() == "HEAD"
AttributeError: 'NoneType' object has no attribute 'upper'
@realgam3 Will you write an answer? I urgently need this module.
Tomorrow I will try to fix it 😊
On Sun, 29 Nov 2020 at 0:19 Phoenix1112 notifications@github.com wrote:
@realgam3 https://github.com/realgam3 Will you write an answer? I urgently need this module.
— You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/realgam3/requests-raw/issues/1#issuecomment-735297849, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABKOSGFS3JM5IIHY5QYOXXTSSFZP5ANCNFSM4P43MGMA .
@realgam3 thanks❤❤ i think problem is Transfer-Encoding: chunked
It's not an easy issue because its in the response and I'm not sure why it has no method.... but I will give you my workaround for this issue until I fix it :)
from requests.packages.urllib3 import response
# Monkey Patch
def _is_response_to_head(response):
"""
Checks whether the request of a response has been a HEAD-request.
Handles the quirks of AppEngine.
:param conn:
:type conn: :class:`httplib.HTTPResponse`
"""
# FIXME: Can we do this somehow without accessing private httplib _method?
method = response._method or ""
if isinstance(method, int): # Platform-specific: Appengine
return method == 3
return method.upper() == "HEAD"
response.is_response_to_head = _is_response_to_head
if __name__ == "__main__":
data = b"""
POST /m_graphql HTTP/1.1
Host: live.kuaishou.com
Connection: close
Content-Length: 418
accept: */*
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/82.0.4157.69 Safari/537.36
content-type: application/json
Origin: https://live.kuaishou.com
Sec-Fetch-Site: same-origin
Sec-Fetch-Mode: cors
Sec-Fetch-Dest: empty
Referer: https://live.kuaishou.com/
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9
Cookie: kuaishou.live.bfb1s=7206d814e5c089a58c910ed8bf52ace5; clientid=3; did=web_86c69fc7a60c69f314ea3cf176531dd9; client_key=65890b29
{"operationName":"categoryListQuery","variables":{"type":"panel","categoryCardList":true},"query":"query categoryListQuery($limit: Int, $type: String, $categoryCardList: Boolean) {\\n categoryList(limit: $limit, type: $type, categoryCardList: $categoryCardList) {\\n categoryId\\n categoryAbbr\\n name\\n category\\n title\\n src\\n shortName\\n gameDescription\\n subList\\n __typename\\n }\\n}\\n"}
""".strip().replace(b"\n", b"\r\n")
print(requests_raw.raw("https://live.kuaishou.com/m_graphql", data=data).text)
@realgam3 thanks <3
Fixed on 1.0.0
Use Python 3 to reproduce this problem:
run the code, raise the exception:
In
/Lib/site-packages/urllib3/response.py:251
:This IF statement is true, and set the self.chunked = true. let the programe run into where the exception is raised