Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Library : Other (not classified elsewhere) » HttpClient example with Post data
Re: HttpClient example with Post data [message #8375 is a reply to message #8353] Tue, 06 March 2007 10:53 Go to previous messageGo to previous message
mikcsabee is currently offline  mikcsabee
Messages: 10
Registered: February 2007
Promising Member
Hello!

Thanks for your answer, but it not works. Confused

Here is my C++ code:
static String DumpSpecial(String s)
{
	String out;
	for(const char *p = s.Begin(), *e = s.End(); p < e; p++)
		if((byte)*p >= ' ' && *p != '\xFF')
			out.Cat(*p);
		else {
			switch(*p) {
				case '\a': out.Cat("[\\a]"); break;
				case '\b': out.Cat("[\\b]"); break;
				case '\f': out.Cat("[\\f]"); break;
				case '\v': out.Cat("[\\v]"); break;
				case '\t': out.Cat("[\\t]"); break;
				case '\r': out.Cat("[\\r]"); break;
				//case '\n': out.Cat("[\\n]\n"); break;
				case '\n': out.Cat("\n"); break;
				default:   out.Cat(NFormat("[\\x%02x", (byte)*p)); break;
			}
		}
	return out;
}

CONSOLE_APP_MAIN
{
		String url = "127.0.0.1/post/index.php";
		puts(url);
		fflush(stdout);
		HttpClient client;
		
		client.Post();
		client.URL(url);
		client.AddHeaders("\n\nvar1=hello&var2=something");


		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);
}


And here is the PHP code in server side:
<?php

echo "\nPOST:\n";
print_r($_POST);

echo"\n\nREQUEST:\n";
print_r($_REQUEST);

print_r(getallheaders());

?>


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 09:35:22 GMT[\r]
Server: Apache/2.0.55 (Ubuntu) PHP/5.1.6[\r]
X-Powered-By: PHP/5.1.6[\r]
Content-Length: 231[\r]
Connection: close[\r]
Content-Type: text/html; charset=UTF-8[\r]

[content] (231 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
)




And what I need? Some data in the Post array.


5e455c75752baefde96699018d86f3d1
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: How to run the email client [SOLVED]
Next Topic: am ashamed to ask for help on this but...
Goto Forum:
  


Current Time: Fri May 10 23:55:55 CEST 2024

Total time taken to generate the page: 0.02744 seconds