Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does %5B and %5D in POST requests stand for?

I'm trying to write a Java class to log in to a certain website. The data sent in the POST request to log in is

user%5Blogin%5D=username&user%5Bpassword%5D=123456

I'm curious what the %5B and %5D means in the key user login.

How do I decode these data?

like image 231
Rakib Ansary Avatar asked Apr 01 '12 16:04

Rakib Ansary


People also ask

What does POST stand for request?

In computing, POST is a request method supported by HTTP used by the World Wide Web. By design, the POST request method requests that a web server accept the data enclosed in the body of the request message, most likely for storing it. It is often used when uploading a file or when submitting a completed web form.

WHAT IS PUT and POST request?

The difference between POST and PUT is that PUT requests are idempotent. That is, calling the same PUT request multiple times will always produce the same result. In contrast, calling a POST request repeatedly have side effects of creating the same resource multiple times.

What is GET and POST in API?

POST vs GETWhile the HTTP POST method is used to send data to a server to create or update a resource, the HTTP GET method is used to request data from a specified resource and should have no other effect. HTTP POST request provides additional data from the client to the server message body.

What are GET and POST used for in a form?

HTTP POST requests supply additional data from the client (browser) to the server in the message body. In contrast, GET requests include all required data in the URL. Forms in HTML can use either method by specifying method="POST" or method="GET" (default) in the <form> element.


2 Answers

As per this answer over here: str='foo%20%5B12%5D' encodes foo [12]:

%20 is space %22 is quotes %5B is '[' and %5D is ']' 

This is called percent encoding and is used in encoding special characters in the url parameter values.

EDIT By the way as I was reading https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/encodeURI#Description, it just occurred to me why so many people make the same search. See the note on the bottom of the page:

Also note that if one wishes to follow the more recent RFC3986 for URL's, making square brackets reserved (for IPv6) and thus not encoded when forming something which could be part of a URL (such as a host), the following may help.

function fixedEncodeURI (str) {     return encodeURI(str).replace(/%5B/g, '[').replace(/%5D/g, ']'); } 

Hopefully this will help people sort out their problems when they stumble upon this question.

like image 94
Boris Strandjev Avatar answered Oct 02 '22 05:10

Boris Strandjev


They represent [ and ]. The encoding is called "URL encoding".

like image 43
ruakh Avatar answered Oct 02 '22 03:10

ruakh