Many languages allow one to pass an array of values through the url. I need to , for various reasons, directly construct the url by hand. How is an array of values urlencoded?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It looks like the content in the form of MIME-Type:
application/x-www-form-urlencoded.Which is used for the POST. To do it for the GET, you’ll have to append a
?after your URL, and the rest is almost equal. In the comments, mdma states, that the URL may not contain a+for a space character. Instead use%20.So an array of values:
Often there is some functionality in libraries that will do the URL encoding for you (point 1). Point two is easily implementable by looping over your array, building the string, appending the index,
=, the URL encoded value and when it’s not the last entry an&.