Hello, I’m trying to POST some data to a web server but I’m not able to send the proper POST message and I was hoping someone could help me narrow the issue down because I’m stumped.
I’m using a wifly library I made in the past. But as you’ll see this isn’t really a library usage question, but a wifly hardware usage question (or maybe a Sc16is750 configuration question).
Things I’ve tried:
I can use telnet and send the HTTP POST message and everything works as expected so I know the text I’m sending is well formed and that my web server is working properly. When using the Arduino & Wifly shield I run into issues after I issue an open command (“open 192.168.1.101 80”). I do get a message saying the connection has been made (“Connect to 192.168.1.101:80”). It seems whatever path I choose after this results in failure. The wifly stays in command mode after the open command (which I assume is normal) so any text sent for the post message is interpreted as a command. And since “POST index.php HTTP/1.1” isn’t a command there is a syntax error. So I assume I need to exit command mode to send the POST message. But if I exit command mode to send the POST message it acts like my web server code never runs. I have my webserver create a dummy file when a connection is made and since no file is made I’m assuming the message never gets sent.
And I can successfully ping my webserver with the wifly using the “ping” command so I know the connection is not blocked.
Do I send the POST text while still in command mode? Ex:
<2.18> open 192.168.1.101 80
Connect to 192.168.1.101:80
<2.18> exit
EXIT
send_string( "POST /index.php HTTP/1.1\r\n" );
send_string( "Host: 192.168.1.101\r\n" );
send_string( "Content-Type: application/x-www-form-urlencoded\r\n" );
send_string( "Content-Length: 6\r\n" );
send_string( "\r\n" );
send_string( "Test=1\r\n" );
or
<2.18> open 192.168.1.101 80
Connect to 192.168.1.101:80
<2.18>
send_string( "POST /index.php HTTP/1.1\r\n" );
send_string( "Host: 192.168.1.101\r\n" );
send_string( "Content-Type: application/x-www-form-urlencoded\r\n" );
send_string( "Content-Length: 6\r\n" );
send_string( "\r\n" );
send_string( "Test=1\r\n" );
If the second how do I avoid the wifly from interpreting the “POST…” data as a command?
Do any of you have suggestions as to how I can debug what text is sent out of the wifly when not in command mode? Like some sniffer or something? I’ve no experience in using one, but I don’t mind, I just wonder if a sniffer will tell me anything.