-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
The set request parameters were not used #8464
Comments
Could you atleast put a snippet of the code you used along with comments explaining what happened at different points? I'm rather struggling to understand your issue from the description. |
The ClientSession in this location has encountered an exception. I used a new ClientSession object here to restore it to normal. My friend said that the parameter may not have been successfully passed. The code here is to download a file and requires a cookie. The normal response code is 206, and the incorrect cookie response code is 403. It is suspected that the headers were not successfully passed here. |
I'm still not clear what the issue is.
The code you shared does not create a new ClientSession, it simply returns False after an exception. I'm rather unclear what you want us to do. If the headers are wrong, that's not something we can help with... |
Replacing aiohttp with https or requests can solve the problem. |
Are you putting parameters in the URL? The most common difference between those libraries is that URLs are escaped by default. See (in particular, the note): https://docs.aiohttp.org/en/stable/client_quickstart.html#passing-parameters-in-urls |
I used aiohttp in my project, and at the location where an exception occurred, I passed in the URL and headers parameters. I copied the URL and headers parameters and tested them using aiohttp code. The test passed, but I suspect that parameter passing failed. My friend has also experienced parameter passing failures, which is not a coding issue. If the headers parameter is not passed, the running result will be the same as this exception result. |
I don't think there's any difference between these libraries regarding passing headers. You're either passing them or you're not. aiohttp isn't going to lose headers. |
Testing the URL and headers parameters using aiohttp, httpx, and requests separately is normal, and aiohttp only experiences exceptions at a specific location in the project. |
I recorded a video, including the location and results of the anomalies, as well as the results of individual tests. If you think this anomaly is not related to aiohttp, I will delete the video. |
If it's a problem with my code, I should get a response code 403 when testing using URL and headers, which is consistent with the response code at the exception location. However, the response code I tested was 206, indicating that it's not an exception in my code. |
The URL in your video is a string with query parameters. Therefore, you probably need to pre-encode (or pass them using The difference in behaviour could be the proxy? Maybe one proxy is actually decoding the URL before passing it through to the endpoint, while the other passes it through unchanged. |
The URL and headers are both directly copied for testing, and the proxy is also set to http://127.0.0.1:10809 If it is a coding issue, the copied test results should be consistent with the abnormal results. |
The code at the exception location and the parameters used in the test code are exactly the same, and the results should also be consistent, but in reality, they are not consistent. I don't know why the headers failed to pass, but as an aiohttp developer, you should have a better understanding. |
Have you tried passing it as a pre-encoded URL as mentioned twice already? Without your code, I can't give any more suggestions than that.. |
I tried many methods, including encoding parameters, but couldn't solve them until I created a new ClientSession or replaced aiohttp with requests or httpx. |
Well, if you just use |
Describe the bug
My project is a crawler program. The program's lifecycle only creates a ClientSession object, and all requests are initiated using this object. However, some requests may encounter exceptions and return incorrect response codes
When I debugged, I used the url and headers separately for code testing, and the response code was normal.
I found that the problem was with the ClientSession. When I used a new ClientSession object to initiate a request at the location where the error occurred, the response code was correct.
Every time the program uses the ClientSession object to initiate a request, it passes in the url and headers, but I don't know why the response code exception only occurs at that location. Could it be that the ClientSession is contaminated?
If I need to resolve this error, I may need to create two ClientSession objects for separate use. Do you have any better suggestions?
To Reproduce
Due to the unique nature of the project, it is not convenient for others to reproduce the bug.
I am testing the TikTok download feature of the project and reproducing the bug 100%.
Expected behavior
I took out the URL and headers separately for testing, and the response code was 206, normal. When there was an exception, the response code was 403.
Logs/tracebacks
Python Version
aiohttp Version
multidict Version
yarl Version
OS
Windows 11
Related component
Client
Additional context
This is my project address: https://github.com/JoeanAmier/TikTokDownloader
It is still under development
ClientSession
Code of Conduct
The text was updated successfully, but these errors were encountered: