Skip to content
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

Questions about yarl behavior #420

Closed
xiafu-msft opened this issue Feb 14, 2020 · 7 comments
Closed

Questions about yarl behavior #420

xiafu-msft opened this issue Feb 14, 2020 · 7 comments
Labels

Comments

@xiafu-msft
Copy link

Hi!

We ran into a problem when we were using yarl.
The problem happens on this line https://github.com/aio-libs/yarl/blob/master/yarl/__init__.py#L170
Before L170 was executed val[2] was /container1/%3B.txt
while after L170 path is /container1/;.txt
So it looks like L170 auto-decoded the encoded path.... How can we send out a request without decode the url?

Your help will be appreciated!

@xiafu-msft
Copy link
Author

Hi! any update on this one

@webknjaz
Copy link
Member

I don't understand what you're trying to achieve and how you use YARL.

@xiafu-msft
Copy link
Author

Hi @webknjaz
Thanks for your reply!
I was trying to send http request to a url which is xiafuhns.blob.core.windows.net/container1/%3B.txt
while after this line https://github.com/aio-libs/yarl/blob/master/yarl/__init__.py#L170 was executed my url became xiafuhns.blob.core.windows.net/container1/;.txt which is a wrong one....

Feel free to let me know if you need any info! And thanks again to help look into that!

@webknjaz
Copy link
Member

You're talking about the low level implementation detail, please show your code.

@AlwxSin
Copy link

AlwxSin commented Apr 23, 2020

Same here. I need to redirect a user to another URL in aiohttp app
raise web.HTTPFound(location=download_url) which follows by self.headers['Location'] = str(URL(location))
But yarl modifies my download URL in unpredict way.

>>> url = 'https://storage.googleapis.com/bucket-name/4badf680bf5%2F0463d893f14%2F6498af44f0%2Fpro%28d%29uction.jpg'
>>> URL(url)
URL('https://storage.googleapis.com/bucket-name/4badf680bf5%2F0463d893f14%2F6498af44f0%2Fpro(d)uction.jpg')

My URL contains 4 parts - {hash1}/{hash2}/{hash3}/{file_name}.{file_ext}. Note that yarl does not modify encoded slashes, only encoded parentheses.

@asvetlov
Copy link
Member

Yarl normalizes URL by quoting all not allowed characters and unquoting all allowed PCT-encoded sequences.
To disable this please pass encoded=True argument to URL() constructor or URL.build() function.

@thuan1412
Copy link

Hi @asvetlov , I face the same issue, but in the update_query method. It automatically normalizes the query. Can we disable it in the update_query method?

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants