Search code examples
postcurlget

How can I make a request with both GET and POST parameters?


Here's an excerpt from Live HTTP headers, I've replaced several values for anonymity.

POST blah/admin.php?module_id=1&action=update&id=129&pageNum=17&&eid=362 HTTP/1.1

Host: blah

User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.12) Gecko/20101027 Firefox/3.6.12

Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8

Accept-Language: en-us,en;q=0.5

Accept-Encoding: gzip,deflate

Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7

Keep-Alive: 115

Connection: keep-alive

Referer: blah

Cookie: blah

Content-Type: multipart/form-data; boundary=---------------------------21278813472729408841849703914

Content-Length: 5110

-----------------------------21278813472729408841849703914

Content-Disposition: form-data; name="MAX_FILE_SIZE"



300000000

This request has both GET and POST values. The script on the other end of this is PHP and expects certain values to be in the GET and others to be in the POST.

I know how to issue a GET

curl -G -d "key=val" "http://yadayadayada"

And I understand how to do a POST

curl -d "key=val" "http://yadayadayada"
curl -F "key=val" "http://yadayadayada"

But how do I mix the two in a single request? Every attempt I've made so far has ended in an error.


Solution

  • GET variables can be included in the URL. You just include the GET variables in the query string. For example, if you wanted to send a GET request with "username=fred" to www.example.com/index.php, you would send a simple GET request to "http://www.example.com/index.php?username=fred". So to answer your question, just use the POST method, but have the URL contain your GET data.