Query string value with %20

Mar 22, 2014 at 7:02 PM
Edited Mar 22, 2014 at 7:05 PM
Hello,
I am sending to my http handler the following request (with Fiddler)

http://localhost:8080/test?Text=J%27ai%20besoin%20de%20trouver%20un%20personnage%20%C3%A9trange

In my code (version 2.0.0) I just print out the query:
void TestHttpListener::handle_get(web::http::http_request request)
{
    std::wcout << request.relative_uri().query() << std::endl;
}
This is what I get:

Text=J%2527ai%2520besoin%2520de%2520trouver%2520un%2520personnage%2520%25C3%25A9trange

The %20 gets converted in %2520.

Do I miss anything?

Thanks,
Pedro
Coordinator
Mar 25, 2014 at 7:38 PM
Hi

This is a bug in our http_listener. Looks like the uri in http_request has been encoded twice by our implementation.
We will fix this for our next release. Meanwhile, one workaround that you can try is to decode the URI (twice to get the original unencoded URI string):
        auto uri_str = request.relative_uri().to_string(); // Get the relative_uri: Due to a bug, this has been encoded twice.
        auto str1 = uri::decode(uri_str); // Get the original encoded relative uri 
        auto str2 = uri::decode(str1); // Get the original unencoded relative uri 
Hope this helps! Thank you for reporting this issue.

Thanks
Kavya
Marked as answer by MsdnDev on 3/31/2014 at 7:11 PM
Apr 1, 2014 at 3:11 AM
Double decode actually works fine.

Thanks,
Pedro
Coordinator
Apr 4, 2014 at 12:59 AM
Hi Pedro,

FYI we fixed this issue in our 2.0.1 release.

Thanks,
Steve