Well, first of all, I want to send data to a php page so that the php page can read values from the POST variables $_POST['foo'] $_POST['bar'] (excuse me for the php code).
Well, first of all, I want to send data to a php page so that the php page can read values from the POST variables $_POST['foo'] $_POST['bar'] (excuse me for the php code).
And the problem is you don't know how to format the data, right?Sorry but this is out of scope of this forum. I suggest you take a network sniffer such as iptraf, ettercap or tcpdump, send a post request to some php page and see how the data is formatted.
Yes that's probably it. Thanks anyway.
Ah, I think I've solved it now.
Qt Code:
const QString s("/url.php Accept: text/html, text /plain, text/css, text/sgml, */* ;q=0.01\nAccept-Encoding : gzip, bzip2\nAccept-Language: en\nPragma: no-cache\nCache-Control: no-cache\nUser-Agent: Foobar\nReferer: http://localhost /a.php\nContent-type:application/x-www-form-urlencoded\nContent-lentgh::17\n"); QHttpobject->post( s, *ba);To copy to clipboard, switch view to plain text mode
The headers should be in the data section, not the path section. The path should only contain "/url.php".
Well, I couldn't make it work if I put it in the data section. The parameters were not received in the webserver.
Did you remember about the extra newline after the last header?
I've added both \n and \n\n after ContentLength: 17 but no success.
If anyone can re-write it properly, feel free to do so, because I can't make it work![]()
Take a network sniffer or netcat and see what the difference is.
Well the difference is big. The real webbrowser gives this extra information
Qt Code:
User-Agent: Links (2.2; Linux 2.6.25-gentoo-r7 x86_64; 150x41) Accept: */* Accept-Encoding: gzip, deflate, bzip2 Accept-Charset: us-ascii, ISO-8859-1, ISO-8859-2, ISO-8859-3, ISO-8859-4, ISO-8859-5, ISO-8859-6, ISO-8859-7, ISO-8859-8, ISO-8859-9, ISO-8859-10, ISO-8859-13, ISO-8859-14, ISO-8859-15, ISO-8859-16, windows-1250, windows-1251, windows-1252, windows-1256, windows-1257, cp437, cp737, cp850, cp852, cp866, x-cp866-u, x-mac, x-mac-ce, x-kam-cs, koi8-r, koi8-u, koi8-ru, TCVN-5712, VISCII, utf-8 Accept-Language: en, *;q=0.1 Connection: Keep-Alive Content-Type: application/x-www-form-urlencodedTo copy to clipboard, switch view to plain text mode
And I can not add any of these without adding them to the path.
Bookmarks