2

I'm using the http listener of the C++ REST SDK 2.8 and noticed the following. If I send the following URL to this listener:

http://my_server/my%2fpath?key=xxx%26yyy%3Dzzz

and I do:

auto uri = request.relative_uri();
auto v_path_components = web::uri::split_path(web::uri::decode(uri.path()));
auto m_query_components = web::uri::split_query(web::uri::decode(uri.query()));

then I find that v_path_components contains 2 elements ["my", "path"], and m_query_components contains 2 pairs [("key","xxx"), ("yyy","zzz")].

What I want and would have expected is v_path_components to contain 1 element ["my/path"], and m_query_components to contain 1 pair [("key","xxx&yyy=zzz")].

In order for the latter to achieve, relative_uri shouldn't decode/encode the uri, as that looses information. In addition, web::uri::decode() should be executed on the split results rather than before splitting. But, as the REST SDK itself as well as many samples shipped with it uses this in the above way, it leads me to believe that I might be wrong.

Could anyone confirm my findings or explain why I'm on the wrong track?

πάντα ῥεῖ
  • 1
  • 13
  • 116
  • 190
Luigi
  • 21
  • 1
  • 3

1 Answers1

0

Your findings make sense.

Since you are decoding first, then the encoded ampersand (%3D) becomes a key/value pair separator. Same for the path components. The slash (%2f) becomes a path separator, and is parsed as such.

yano
  • 4,095
  • 3
  • 35
  • 68