Most of you must heard about URI Encoding...
Why do we need to Encode URIs?
It is because otherwise servers cannot identify what we sent there.
When we are accessing/using urls we cannot add spaces there. While sending a GET request you may want to add spaces there. Then how do you send those data..?
When we are accessing/using urls we cannot add '/' there. '/' is reserved for use as a component separator. Then how do you send those data..?
Consider that you want to send a XML file attached there..
Here comes the URI encoding.
For example:
you want to encode this
http://www.mysite.com/?XML=<cs><o n="authcode" v="d82709ae"/><c n="FlightSearch"><q n="StartDate" v="18-May-2015"/><q n="EndDate" v="21-May-2015"/></c></cs>
into this
http://www.mysite.com/?XML=%3Ccs%3E%0A%3Co%20n=%22authcode%22%20v=%22d82709ae%22/%3E%0A%3Cc%20n=%22FlightSearch%22%3E%3Cq%20n=%22StartDate%22%20v=%2218-May-2015%22/%3E%0A%3Cq%20n=%22EndDate%22%20v=%2221-May-2015%22/%3E%3C/c%3E%0A%3C/cs%3E
You can try it here..
URL:
Cheers...!!
Why do we need to Encode URIs?
It is because otherwise servers cannot identify what we sent there.
When we are accessing/using urls we cannot add spaces there. While sending a GET request you may want to add spaces there. Then how do you send those data..?
When we are accessing/using urls we cannot add '/' there. '/' is reserved for use as a component separator. Then how do you send those data..?
Consider that you want to send a XML file attached there..
Here comes the URI encoding.
For example:
you want to encode this
http://www.mysite.com/?XML=<cs><o n="authcode" v="d82709ae"/><c n="FlightSearch"><q n="StartDate" v="18-May-2015"/><q n="EndDate" v="21-May-2015"/></c></cs>
into this
http://www.mysite.com/?XML=%3Ccs%3E%0A%3Co%20n=%22authcode%22%20v=%22d82709ae%22/%3E%0A%3Cc%20n=%22FlightSearch%22%3E%3Cq%20n=%22StartDate%22%20v=%2218-May-2015%22/%3E%0A%3Cq%20n=%22EndDate%22%20v=%2221-May-2015%22/%3E%3C/c%3E%0A%3C/cs%3E
You can try it here..
URL:
Cheers...!!
No comments:
Post a Comment