22

I can't find a precise answer on that question :

Are parameters which are sent by PUT passed in the URL, or in the HTTP header ?

I think it's the HTTP header, but when I submit my form with the PUT method, it appends the parameters to the URL !

naXa
  • 26,677
  • 15
  • 154
  • 213
DKF
  • 377
  • 2
  • 4
  • 10

2 Answers2

29

Are parameters which are sent by PUT passed in the URL, or in the HTTP header ?

Not the headers. It's the same as POST - either the URL or the body of the request. The only difference is the HTTP verb being used and of course the semantics that come with it (UPDATE a resource on the server).

Darin Dimitrov
  • 960,118
  • 257
  • 3,196
  • 2,876
  • 2
    I didn't know that POST could send data by URL ! Isn't it only in the HTTP request body ? --- So it means that PUT can send data like http://www.example.com?param=value OR into the Request Body ? – DKF Sep 25 '12 at 08:15
  • 3
    Both are possible URL and body. I would avoid it though. I would only use the body. – Darin Dimitrov Sep 25 '12 at 08:16
  • Okay, thank you very much ! So it means that in my case, it is the server which automatically put the parameters in the URL after I hit the submit button ? – DKF Sep 25 '12 at 08:21
  • 2
    What submit button? Are you talking about an HTML web page with a `
    `. Most browsers support only the GET and POST verbs, not PUT. You will have to use AJAX if you want to use the PUT verb from a web page. And no, it is not the server that is adding anything to the request. It's the client. In the case of an HTML `
    ` this is described in the [HTML specification](http://www.w3.org/TR/html401/interact/forms.html). If you are using `method="GET"` then the browser will add all input field values that are inside the form to the query string. If you use POST it will add them to the body.
    – Darin Dimitrov Sep 25 '12 at 08:23
  • Yes I use a `
    ` to do my tests. Thanks for the advices !
    – DKF Sep 25 '12 at 09:45
4

Your question seems to be about HTML forms. In which case the answer is: they do not support PUT (the browser still sends a POST request instead).

If it's not about HTML forms: it's up to you. For instance, in XmlHttpRequest you can use both.

Julian Reschke
  • 35,455
  • 7
  • 78
  • 83