This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

POST and GET to the same .cgi file

Hi,

I'm currently interfacing to an external module which has a pre-defined protocol that I'm trying to comply with. The module uses both GET and POST messages to the same cgi file, for example;

Get example;
GET http://<server>/<filename>.cgi?req=<parampath>

Post example;
POST http://<server>/<filename>.cgi\r\n
content-Length:XX\r\n
\r\n
<paramPath>=<value>\r\n

I can successfully capture and action the GET messages sent by the external module via the cgi_process_var() . I don't however seem to be able to capture and action the POST messages via the cgi_process_data(). The cgi_process_data() never seems to be called on receipt of the POST message.

Is it possible to do both methods via the same cgi file?

I've tried to look at the cgi script language to see if there is anything I should be including in my cgi file but i cannot see anything other then possibly including a <FORM> element?(http://www.keil.com/support/man/docs/rlarm/rlarm_tn_http_scriptlang.htm)

My cgi file currently only contains a call to the cgi_func() via the simple script "c S E %s" to allow me to send back a custom strings to the module.

Apologies in advance for the gaps in my knowledge on this subject.

Thanks

Tom

Parents
  • In this case both should be possible, but it depends how are GET and POST requests generated? (from a special client application using Web-sockets or from a standard Web browser)

    For standard Web browser it is on you to design a web page so that a click in the browser on ie. section A would generate GET request, but a clieck on section B would generate POST request.

Reply
  • In this case both should be possible, but it depends how are GET and POST requests generated? (from a special client application using Web-sockets or from a standard Web browser)

    For standard Web browser it is on you to design a web page so that a click in the browser on ie. section A would generate GET request, but a clieck on section B would generate POST request.

Children
  • Them both being possible sounds like good news.

    We have a http server with two sessions (one for the requests from the discussed external unit and one for our simple config browser page) both on port 80.

    The requests are generated by the external unit, there is no web browser under our control for these requests. It is possible to simulate/replicate the requests being sent by the external equipment by using HTTP-Client software like "I'm Only Resting" from Swensen Software.

    Some example messages that are sent to us (assuming our IP is 192.168.100.23) to process would be;

    Get Example;

    The request would be in the format;
    GET 192.168.100.23/.../param.cgi

    Our response is in the format
    HTTP/1.0 200 OK\r\n
    Content-Type: text/html\r\n
    \r\n
    General.UnitName=My Name\r\n

    Post Example;

    The request would be in the format;
    POST 192.168.100.23/.../param.cgi\r\n
    Content-Length: 26\r\n
    \r\n
    General.UnitName=New Name\r\n

    Our response to confirm the would be;
    HTTP/1.0 200 OK\r\n
    Content-Type: text/html\r\n
    Content-Length: 26\r\n
    \r\n
    General.UnitName=My Name\r\n

    Thank you for your continued support.

  • I have been continuing work on this subject and it seems my problem may be a little more basic/fundamental.

    I have gone back to trying to implement the Keil example for POST as described in the "Getting Started Building Applications with RL-ARM" to check that POST commands work on their own. Unfortunately there seems to be a problem with my project as the "change" button in the example also doesn't trigger CGI_process_data().

    cgi_process_var() and cgi_func() are both OK and have been seen to work.

    I have used wireshark and can see the HTTP POST request coming from the web browser, I can also see the stack ACK via TCP the HTTP POST. After this I would expect the CGI_process_data() to be called but this doesn't happen.

    I'm using what I think is the latest legacy library ( __RL_TCP_VER 0x00000477 Number 0 at_system.o ABSOLUTE) .

    Does anybody have any ideas on what I could be overlooking?

    Thanks

    Tom