PDA

View Full Version : HTTP Post in 7.5b


TracyP
07-06-2010, 10:05 AM
I have setup an HTTP action
Put: Post form data
Get: Get to macro
URL: myurl.php
Macro: PostResponse
Do not escape special characters: not checked
Transfer type: ASCII
Form Data: action=3&program_date=07/06/2010
Logging: All + Hex dump

--

The php script I'm posting to is not getting the Form Data.
The Hex dump is not showing the Form Data.

Any suggestions?

[correction]
I didn't look high enough, the data did get sent. The PHP script isn't seeing the data though.

kinook
07-06-2010, 11:03 AM
I'm not sure. Testing the attached sample w/ 7.5b on Windows XP SP3 produces the expected output of

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="en-US">
<head>
<title>Echoing submitted form data</title>
</head>
<body>
<h1 style="font-size:1.2em">Echoing submitted form data</h1>
<table border="1" cellspacing="0">
<tr><th align="left" nowrap><tt>Comments</tt></th><td nowrap><tt>xyz</tt></td></tr>
<tr><th align="left" nowrap><tt>box</tt></th><td nowrap><tt>yes</tt></td></tr>
</table>
<p>Processed 2010-07-06T16:01Z
</p>
</body>
</html>

http://www.kinook.com/Forum/showthread.php?threadid=3044

TracyP
07-06-2010, 05:48 PM
I downloaded Fiddler to discover the problem. It appears when posting data the Content-Type header needs to be set to 'application/x-www-form-urlencoded'.

This worked in the 6.x version I was using prior to upgrading the system and software.


Watching what is posted via VBP

POST http://powerchurchsoftware.com/test/index.php HTTP/1.1
Host: powerchurchsoftware.com
Content-Length: 19

action=3&version=A0

returns

HTTP/1.1 200 OK
Date: Tue, 06 Jul 2010 22:34:18 GMT
Server: Apache
X-Powered-By: PHP/5.2.13
Vary: Accept-Encoding
Content-Length: 13
Content-Type: text/html

array(0) {
}


Changing the post to this:

POST http://powerchurchsoftware.com/test/index.php HTTP/1.1
Host: powerchurchsoftware.com
Content-Length: 19
Content-Type: application/x-www-form-urlencoded

action=3&version=A0

Properly returns the array


HTTP/1.1 200 OK
Date: Tue, 06 Jul 2010 22:45:51 GMT
Server: Apache
X-Powered-By: PHP/5.2.13
Vary: Accept-Encoding
Content-Length: 77
Content-Type: text/html

array(2) {
["action"]=>
string(1) "3"
["version"]=>
string(2) "A0"
}

kinook
07-06-2010, 06:40 PM
Add a value that requires encoding (spaces or special characters, i.e., action=3&version=A0
&x=a b). The version of the third-party networking component used in v7 only adds the Content-Type header if there are values that require encoding.

TracyP
07-07-2010, 08:32 AM
OK, added an extra variable and the array is filled in.

Thank you.

kinook
07-07-2010, 08:49 AM
Also, in v7.6, you can explicitly set header values (Options tab).

TracyP
07-07-2010, 09:23 AM
I like that idea better.
Thanks for the new release.