I would like to know how the HTTP request URL will be encoded in client application. Also i want to know what's the the Default encoding in web browser and how can i change the default encoding in diff web browser. please anyone suggest a solution.
Asked
Active
Viewed 649 times
-1
-
What is apln? What web browser? What did you try so far? Please be more specific – nikolas Aug 07 '13 at 07:29
-
@nijansen Do u know how to encode URL in HTTP request?? – Rono Aug 07 '13 at 07:51
-
What request? HTTP/1.0 defines 3 different request types, and HTTP/1.1 adds 5 more request types. What do you mean with "encode"? HTTP requests are sent in plain text with `"\r\n"` endings. – nikolas Aug 07 '13 at 08:02
-
@nijansen->In Content-Type header we can apply our Encoding type like Content-Type: text/html; charset=utf-8 or With the use of this Header ->Accept-Charset: ISO-8859-1. Please refer the following linkhttp://www.w3.org/International/O-HTTP-charset – Rono Aug 07 '13 at 08:08
-
That asks the server for a certain response encoding, but has nothing to do with the request itself. The request url is not encoded. – nikolas Aug 07 '13 at 08:17
-
@nijansen But i have a issue regarding the space in Request URL.When i given a request like this "http://localHost:8080/Server/Search?value= Abc Abc" this will be encoded in Server like Abc%20Abc. my issue comes here that if my actual data conatins any %20 what will happen? – Rono Aug 07 '13 at 08:22
-
Don't transmit data as request parameters. It's unsafe, very restricted in length, and has encoding restrictions as you noticed. Use a `POST` request and the data field of that request to transmit your data. If it absolutely must be request parameters, you will have to do something like a base64 encoding, but please just don't. You will get yourself in more problems than just learning how to make a POST request – nikolas Aug 07 '13 at 09:31
-
Actually we want to keep it in url itself.So Can u please explain How can i use the base64 encoding? – Rono Aug 07 '13 at 10:11
1 Answers
1
If you are sending the parameters in the HTTP GET
request in the format ?key=value&..
pairs then to escape the values so that " "
becomes %20
and an input %20
becomes its escaped %2520
you apply urlencoding; Encode/Decode URLs in C++
The same goes for an HTTP POST
except the keys/values are in the request body.
-
> Okay, I can use urlencoding in my Http Client application.But my problem is that how can i encode the url when i use the web browser as Client. – Rono Aug 07 '13 at 10:53
-
ALex, Is there any way to specify the Encoding Type in web Browser( IE, Chrome, Firefox ) – Rono Aug 07 '13 at 11:05
-
A web browser performs url encoding automatically if you navigate to `foo.com/a.b?c=d e f` – Alex K. Aug 07 '13 at 11:06
-
*Encodings* in terms of browser/http relate to character encodings which is not related to url encoding (http://en.wikipedia.org/wiki/Character_encodings_in_HTML) – Alex K. Aug 07 '13 at 11:07
-
Actually i want to use my HTTP Server in both Web Browser and Client Apppln. So how can i resolve the space issue? – Rono Aug 07 '13 at 11:10
-
What space issue? If you navigate to/submit a form to a web server in a browser the browser will apply url-encoding (if you implement an API its up to the caller/callers library to do it). If you send textual http data to a web server from other software that does not automatically apply url-encoding, you must apply it manually. On the server side - depending on web server software - you can usually read the query string parameters and they will be returned after automatic url-decoding. – Alex K. Aug 07 '13 at 11:23
-
If this does not answer your question you will need to edit/post a new one with more details of exactly what your trying to do. – Alex K. Aug 07 '13 at 11:24
-
>But i have a issue regarding the space in Request URL.When i given a request like this "localHost:8080/Server/Search?value= Abc Abc" this will be encoded in Server like Abc%20Abc. my issue comes here that if my actual data conatins any %20 what will happen? Note: Am not using any encoding. This is the default behavior of server. – Rono Aug 07 '13 at 12:32
-
Then (depending on how you submit the request) `%20` will be urlencoded to `%2520%` and urldecoded to `%20` (not a space) – Alex K. Aug 07 '13 at 12:38
-
> No, In this case no encode/ decode operation occurred here, just a minor change in the query string like Abc%20Abc – Rono Aug 07 '13 at 13:08
-
Sorry, I don't follow. Best you post a new question in relation to urlencoding. – Alex K. Aug 07 '13 at 15:10