davidmoreno / onion

C library to create simple HTTP servers and Web Applications.
http://www.coralbits.com/libonion/
Other
2.02k stars 250 forks source link

How to parse url #217

Closed jackweiwang closed 7 years ago

jackweiwang commented 7 years ago

http://192.168.100.161:8080/?url=http://img5.duitang.com/uploads/item/201610/23/20161023144226_c3BUn.jpeg

This is what I want to parse ,But Now I can only pass 'onion_request_query' get jpeg url, How do I access the url after the parameter and get the image, I don't know what should i do?

I hope you can give me a Example or suggestion.

thank you!

davidmoreno commented 7 years ago

Questions like this should be asked in the mailing list, as it is not a bug nor feature.

Anyway as far as I understand your question, you want not only to get the url data, but parse again the url in it and get the path in it.

For the first use onion_request_get_query(request, key) which returns the value of "http://img5..." and to parse this you will have to use some third party library or code it yourself.

Onion does not have a URL parsing in it. It only parses as much as it would need to be a server.

The code anyway is easy if you only want the path and it is always with the same format, or if you just wan the image name (basename(3) is your friend).

If your question is more on the line to download the image and have it somewhere, sorry, you must look for it somewhere else, like in the curl library. Actually it might be used for the URL parsing code too.

Regards, David.