2

What is the usual way to embed the query parameters in the original URL in the http request URL, e.g.

http://www.portal.mywebsite.com/res_a/res_b?orig=http://myorigin.com/test1/test2?q1=v1&q2=v2

How to pass the query parameters q1=v1&q2=v2 that are meant to be in the original url to this new url request?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
wei
  • 6,629
  • 7
  • 40
  • 52

1 Answers1

3

The solution is called URL-encoding.

Regardless of their content, you're supposed to always URL-encode the individual request parameter name and value. Ultimately, your URL should end up looking like this, when using UTF-8 charset during encoding:

http://www.portal.mywebsite.com/res_a/res_b?orig=http%3A%2F%2Fmyorigin.com%2Ftest1%2Ftest2%3Fq1%3Dv1%26q2%3Dv2

Every self-respected programming language has an API for this job. Based on your question history, you're familiar with Java, so here's a related question with a Java based example in the answer: Java URL encoding of query string parameters. For other languages, just search around using the additional keywords "URL encoding".

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Thanks, is there an open source lightweight C library for this job? – wei Aug 25 '13 at 02:29
  • You're welcome. Sorry, I don't do C so I can't tell off top of head, but here's a link I think is helpful: http://stackoverflow.com/search?q=%5Bc%5D+url+encoding – BalusC Aug 25 '13 at 02:29