login about faq
$request = new CkHttpRequest();

$response = $http->PostUrlEncoded('http://something.com/index.php?id=10', $request);
In this sample, 'http://something.com/index.php?id=10 is not working. Basically Chilkat removes ?id=10 (GET parameter)

How can i post data with GET?

asked Sep 10 '12 at 12:42

chilkat's gravatar image

chilkat ♦♦

I'll describe some very basic rules of the HTTP protocol.

1) Any HTTP request (and response) is composed of a "start line" followed by a MIME message. The "start line" contains the HTTP verb, such as "GET", "POST", "PUT", etc., the path of the resource being accessed, and the HTTP protocol version, such as "1.1". The MIME is composed of MIME headers followed by a MIME body (if not empty).

2) A GET request implies that the request params are URL encoded in the path on the "start line". A GET request implicitly has a 0-length MIME body, so you only have the "start line" followed by the MIME headers. This would be a valid GET request:

GET /index.php?id=10&file_id=1&password=abc&submit=Show HTTP/1.1
Accept: /
Accept-Encoding: gzip
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Accept-Language: en-us,en;q=0.5
Host: something.com

3) A POST request implies that the request parameters are provided in the MIME body of the request, not in the "start line". The "start line" provides the path to the resource. The server-side should process a request by obtaining the path to the resource (from the start-line), and then obtain the form parameters from the MIME. (However, if some form params are included w/ the path in the "start line", then these should be parsed as params and should not be considered as part of the path to the resource.) Here is an example of a straightforward and reasonable HTTP POST request that follows the rules of the HTTP protocol:

POST /index.php HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Host: something.com
Content-Length: 40


What you are requesting is a mixture of the two. You're asking for a POST such that one form param is provided as part of the path within the "start line", and the remainder are included in the request's MIME body. You would like to send this:

POST /index.php?id=10 HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Host: localhost
Content-Length: 34


Here we see that "id" is specified in the "start line", and the other form params are provided in the MIME body. The server-side should be parsing this exactly the same as in the case where the form params are all contained in the body, because the path to the resource is "/index.php". It is NOT "/index.php?id=10". In other words, in all three cases above, the resource should be identified as "/index.php", with 4 form params, the names of which are "id", "file_id", "password", and "submit".

Unfortunately, it must be that the server-side is incorrectly implemented because it deems the resource's path as "/index.php?id=10".

To get the desired HTTP request (where "id" is specified in the "start line") use SynchronousRequest instead:

$request = new CkHttpRequest();

$response = $http->SynchronousRequest('something.com', 80, false, $request);


answered Sep 10 '12 at 13:35

chilkat's gravatar image

chilkat ♦♦

edited Sep 10 '12 at 13:39

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: Sep 10 '12 at 12:42

Seen: 14,997 times

Last updated: Sep 10 '12 at 13:39

powered by OSQA