views:

192

answers:

1

I have a restful webservice which receives some structured data which is put straight into a database.

The data is send from an OS using wget. I am just wondering whether I actually need to URL encode the data and if so why? Please note that it is no problem to do it but it might be uneccessary in this scenario.

+3  A: 

If your data has characters that aren't allowed in urls, you should url encode it.

The following characters are either reserved (like &) or just present the possibility of confusing code. If your data contains these characters, urlencode it. Remember if you are using any extended ascii characters, unicode characters or non-printable characters you should url-encode your data.

  • Dollar ("$")
  • Ampersand ("&")
  • Plus ("+")
  • Comma (",")
  • Forward slash/Virgule ("/")
  • Colon (":")
  • Semi-colon (";")
  • Equals ("=")
  • Question mark ("?")
  • 'At' symbol ("@")
  • Space
  • Quotation marks
  • 'Less Than' symbol ("<")
  • 'Greater Than' symbol (">")
  • 'Pound' character ("#")
  • Percent character ("%")
  • Left Curly Brace ("{")
  • Right Curly Brace ("}")
  • Vertical Bar/Pipe ("|")
  • Backslash ("\")
  • Caret ("^")
  • Tilde ("~")
  • Left Square Bracket ("[")
  • Right Square Bracket ("]")
  • Grave Accent ("`")

More info can be found here: http://www.blooberry.com/indexdot/html/topics/urlencoding.htm

vfilby
the data is posted (the web service only accepts post). so it would not use query strings so the problem does not exist or does it? sorry I am no HTTP expert.
csetzkorn
Even though it isn't in the actual url, it is still a part of the request and I believe that url encoding is recommended.
vfilby
vfilby still wonder why though - sorry for being a pain
csetzkorn
Wondering why you should url encode post data?
vfilby