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

1305Re: [json] Glad to be here, some questions?

Expand Messages
  • Tyler Close
    Jul 21, 2009
      On Tue, Jul 21, 2009 at 10:03 AM, Kris Zyp<kriszyp@...> wrote:
      > gearond@... wrote:
      >> (1) When sending a new record to a service, via POST, do you:
      >> (a) append the raw JSON string below the HTTP headers, etc using
      >> which mime type?
      >>
      > RFC 4627 specifies application/json (and I highly recommend that you
      > follow that advise)

      From a practical perspective, it is better to label your POST entity
      as Content-Type "text/plain", since this will be handled more
      efficiently in cross-domain requests from the browser. See:

      http://www.w3.org/TR/access-control/#simple-method

      Following the RFC will cost you an additional network round-trip for
      every unique URL in your application.

      AFAICT, very few JSON services use application/json, so your code
      should be tolerant of responses with other Content-Type header values.

      I recommend using the web_send library
      <http://waterken.sf.net/web_send> for generating your JSON requests.
      It already handles things like the Content-Type for you.

      --Tyler

      --
      "Waterken News: Capability security on the Web"
      http://waterken.sourceforge.net/recent.html
    • Show all 5 messages in this topic