开发者

How this URL will be decoded - Confusion in basic Http Get

Basically I need to pass three paramaters to a http as get. Here are the parameters

param1 = 3
param2 = 454
param3 = http://localhost:3000/another_test?another_param=4&another_param2=978

This transforms to

http://localhost:3000/test?param1=3&param2=454&param3=http://localhost:3000/another_test?another_param=4&another_param2=978

I am just confused whether the URL formed is correct or not. Will this work or is there anyother way to do this. I am using Rails. I did a decode and clicked on the开发者_开发问答 link and I still see the above URL coming. Will this work on the receiever side, meaning will it be decoded as I had intended.

Please advise.


It should work as long as you url encode the params. In that case the & and ? will be transformed, making it possible for Rails to differentiate between the query string parameters and the query string delimiters.

To ensure that it is encoded you can use Rack::Utils.escape or Hash#to_query.


This will be decoded as:

param1=3
param2=454
param3=http://localhost:3000/another_test?another_param=4
another_param2=978

You need to encode param3, or at minimum replace the ampersands in it with the correct URL encoding, in order for it to match back up to your input parameters.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜