Loading ...
Sorry, an error occurred while loading the content.

4531HTTP 202 Accepted and Polling for Completion.

Expand Messages
  • Benjamin L Yu
    Sep 2, 2004
    • 0 Attachment
      I have a situation that I'd like get opinions on from the rest
      community, if people are willing. I don't remember reading anything
      specific covering it in the list archive, so I'm posting it now. :)

      I'd like clarification about how to handle long run back end
      processes. For example:

      ===
      POST /reportmaker HTTP/1.1
      Host: foo.com
      ...

      HTTP/1.1 202 Accepted
      Location: http://foo.com/report/newid
      ===
      GET /report/newid HTTP/1.1
      Host: foo.com
      ===

      If the report has not been created (work is in progress), what should
      I return?

      Here are some of my thoughts:
      1. A 204 No Content status code doesn't fit. 204 states that the
      processing was completed but there is no content, which this is not
      the case.
      2. Return a 200 status code, and set the Content-Type header field to
      something like "application/X-status-message". The body could be an
      XML document detailing the status. Upon completion, the proper content
      and content-type will be returned.
      3. Return a 200 and an X-Status header with some in-progress status
      message.
      4. Return a 200 and an X-Status header with no body.
      5. A 202 Accepted doesn't make sense. Using this would imply that
      server accepted the GET for processing, not the original POST.

      I'm thinking that either 2, 3 or 4 would be the best options (3 and 4
      are essentially the same). I'm gravitating towards 2.

      A slight tangent: I also thought of a different design that I would
      prefer not to use for a reason I will state later:

      ===
      POST /reportordermaker HTTP/1.1
      Host: foo.com
      ...

      HTTP/1.1 201 Created
      Location: http://foo.com/orders/newid
      ===
      GET /orders/newid HTTP/1.1
      Host: foo.com

      HTTP/1.1 200 OK
      Content-Type: application/xml

      <order>
      <status>notdone</status>
      </order>
      ===
      GET /orders/newid HTTP/1.1
      Host: foo.com

      HTTP/1.1 200 OK
      Content-Type: application/xml

      <order>
      <status>done</status>
      <location>http://foo.com/report/newid</location>
      </order>
      ===
      GET /report/newid HTTP/1.1
      Host: foo.com

      ... etc ...
      ===

      The reason I don't want to create orders is that the reportmaker will
      want to generate a report and return a 201 Created (along with
      content) on the first POST by default. But there may be cases where
      the process will take a long time, so I will want to return a 202
      accepted. I would prefer to be able to return the report on the
      majority of the POST requests than to for the client software to
      process multiple round trips of the second example (reportordermaker).

      Comments?

      Thanks,
      Ben
    • Show all 4 messages in this topic