Announcement

Collapse
No announcement yet.

Setting HTTP Response Status

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Setting HTTP Response Status

    I was wondering how I would go about setting the HTTP Response code to a Http POST Request. I was wanting to set the response to be a 204 so that the content of the page would stay intact after a Standard POST. Can you give me an idea of how to do this?

  • #2
    HTTP Response codes

    See the sample code cgi.c callback function, where it processes the POST request. HttpSendError does the job. You would set parameter 2, called "code", to be "204".

    Comment


    • #3
      Http Status Code

      My issue is that Safari responds differently to the response that I am sending back than Internet Explorer and Firefox. Right now after a Standard POST I am doing the following in my callback function:

      uint32_t ProcessPost(HttpClient *pClient)
      {
      Saving Post Information....
      HttpWriteData("HTTP/1.1 204");
      }

      This seems to work fine for Firefox and IE, since they do not refresh the documents content. But in Safari the content is refreshed to show a blank page. So I tried your suggestion:

      uint32_t ProcessPost(HttpClient *pClient)
      {
      Saving Post Information....
      HttpSendError(pClient, "204", "No Content", NULL);
      }

      This then made it so the content of all the browsers refreshed. Now if I did the following:

      uint32_t ProcessPost(HttpClient *pClient)
      {
      Saving Post Information....
      HttpWriteData(pClient, "HTTP/1.1 204");
      HttpSendError(pClient, "204", "No Content", NULL);
      }

      It seems to do closer to what I would expect, none of the browser refresh their content documents but when you look at the response I get a HTML page that says "200 Rebooting". Is there a way to specifically set the status line of the Response Header? I would like to define the status line to be "HTTP/1.1 204 No Content"... Is this possible? I am just thrown off using a send error function when I am not trying to send an error. Thanks!

      Comment


      • #4
        With regard to the "200 Rebooting" response, you need to return from SDKMain() before processing HTTP requests. If you don't, it will appear to Evolution that the boot up process is still in progress.

        The sample file cgi.c demonstrates this using HttpDynamicCallbackAdd.

        Comment


        • #5
          Question about SDKMain and CGI.c

          I am a bit confused. Where is the SDKMain function? Our program gets started from the SDKUserAppStart function in startup.c, is this the function that you are talking about? Also I've been referred to the cgi.c file twice. My SDK does not include a file called cgi.c, am I missing a file I should have? I only have sample0 - sample11.c files.

          Comment


          • #6
            My mistake. We are supporting two SDK's on this forum, and I thought we were talking about the Matchport AR and b/g Pro SDK.

            cgi.c is provided in the Matchport AR SDK, not the XPort AR SDK so this does not apply to you. You are not missing a file.

            And yes, you need to return from SDKUserAppStart.
            Last edited by jwilson; 02-26-2009, 04:35 PM.

            Comment

            Working...
            X