When requesting with http post method, is there a specification defined for using not only the request body but also the query string?

Asked 2 years ago, Updated 2 years ago, 81 views

POST /tokens?epoch=12345 HTTP/1.1
Content-Type: application/x-www-form-urlencoded; charset=utf-8
Host: example.com
Connection: close
Content-Length: 11

epoch=54321

If you have HTTP POST reqeust like above

When there is a variable called epoch in the query string, and when there is a variable called epoch in the request body,

Should the web server receive 12345 as the value of epoch? Do I have to get it by 54321...?

In the case of python django, I think it will be 12345, 54321 as request.GET['epoch'] and reqeust.POST['epoch'] respectively...

If the web server does not distinguish query string from requester body and processes it with the same variable (?),

I wonder which comes first.

Also, I wonder if it is non-standard or standard to use query string together during POST reqeust in the first place.

In the case of ruby on rails, it seems that the request body and query string are received at the time of post.

Is there any rfc spec related to that...? If you know it, please send me a link too!

http rfc query-string

2022-09-22 20:40

1 Answers

query string is included in the URL part.

Therefore, there is no restriction if the method is used for post and put instead of get.

However, as you asked me, I don't use it as much as possible because if the parameter values are duplicated, there may be ambiguous parts such as implementation may vary slightly from framework to framework.

https://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.2.2


2022-09-22 20:40

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.