Home » U++ Library support » U++ Library : Other (not classified elsewhere) » HttpClient example with Post data
Re: HttpClient example with Post data [message #8387 is a reply to message #8353] |
Tue, 06 March 2007 19:31   |
mikcsabee
Messages: 10 Registered: February 2007
|
Promising Member |
|
|
Thanks for your help, but it still not working
Here is my program code:
String url = "127.0.0.1/post/index.php";
String request, data, reply;
data << "var1=hello&var2=fallingdutch";
request << "Content-Length: "<< (int) data.GetLength()<<"\r\n";
request << "Content-Type: txt/xml\r\n\r\n";
puts(url);
fflush(stdout);
HttpClient client;
client.ClearHeaders();
client.Post();
client.std_headers = true;
client.Headers(request);
client.AddHeaders(data);
client.URL(url);
String content = client.Execute();
puts("[error] " + Nvl(client.GetError(), "OK (no error)"));
puts(NFormat("[status %d] %s\n", client.GetStatusCode(), client.GetStatusLine()));
puts(NFormat("[headers] (%d bytes)\n%s", client.GetHeaders().GetLength(), DumpSpecial(client.GetHeaders())));
puts(NFormat("[content] (%d bytes)\n%s", content.GetLength(), DumpSpecial(content)));
fflush(stdout);
The PHP script is same.
And here is the output:
Quote: |
127.0.0.1/post/index.php
[error] OK (no error)
[status 200] HTTP/1.1 200 OK
[headers] (184 bytes)
Date: Tue, 06 Mar 2007 18:24:12 GMT[\r]
Server: Apache/2.0.55 (Ubuntu) PHP/5.1.6[\r]
X-Powered-By: PHP/5.1.6[\r]
Content-Length: 288[\r]
Connection: close[\r]
Content-Type: text/html; charset=UTF-8[\r]
[content] (288 bytes)
POST:
Array
(
)
REQUEST:
Array
(
)
Array
(
[URL] => http://127.0.0.1/post/index.php
[Host] => 127.0.0.1
[Connection] => close
[Accept] => */*
[Accept-Encoding] => gzip
[Agent] => Ultimate++ HTTP client
[Content-Length] => 28
[Content-Type] => txt/xml
)
|
I use Ubuntu Linux 6.10 whit fresh updates, and Ultimate++ 2007.1beta3
I dont know what is the problem.
5e455c75752baefde96699018d86f3d1
|
|
|
Goto Forum:
Current Time: Mon Apr 28 05:10:54 CEST 2025
Total time taken to generate the page: 0.00864 seconds
|