theelous3 / asks

Async requests-like httplib for python.
MIT License
508 stars 63 forks source link

Passing string to ask.get() with ; #59

Closed JK87iab closed 6 years ago

JK87iab commented 6 years ago

Hi, I am trying to use asks for OSRM server requests.

I am sending a list of urls to my server.

Small example:


 async def main():
  r = await asks.get('http://35.204.249.209:5000/route/v1/driving/-73.62818000,40.75193800;-73.6356926,40.7418803?overview=simplified')
  print(r)

curio.run(main())

results in a bad request, because the OSRM server only gets

[info] 15-03-2018 15:54:39 0.064683ms 54.89.111.179 - python-asks/1.3.10 400 /route/v1/driving/-73.62818000,40.75193800?overview=simplified

And if I replace the ; with something else the OSRM gets the full URL (but of course its not working)

async def main():
  r = await asks.get('http://35.204.249.209:5000/route/v1/driving/-73.62818000,40.75193800%TEST-73.6356926,40.7418803?overview=simplified')
  print(r)

curio.run(main())

results in [info] 15-03-2018 15:59:10 0.110487ms 54.89.111.179 - python-asks/1.3.10 400 /route/v1/driving/-73.62818000,40.75193800%TEST-73.6356926,40.7418803?overview=simplified

What is the problem with passing ; in an URL?

EDIT:

If I replace ; with %3B it works, is there an option for automatic encoding?

theelous3 commented 6 years ago

This should be handled. I'll look in to it over the weekend and whip it up. Will prob just refactor that whole area tbh, it's a shitshow as is.

theelous3 commented 6 years ago

This comments is an oops.

theelous3 commented 6 years ago

New code as of https://github.com/theelous3/asks/commit/dfc708a764fa2afd80e6743e8c2b2431f33f880c outputs:

>>> import asks
>>> import curio
>>> asks.init('curio')
>>> 
>>> async def wat():
...     r = await asks.get('http://httpbin.org/get/-73.62818000,40.75193800;-73.6356926,40.7418803?overview=simplified')
...     print('url', r.url)
... 
>>> curio.run(wat)
url http://httpbin.org/get/-73.62818000,40.75193800;-73.6356926,40.7418803?overview=simplified