<?xml version="1.0" encoding="US-ASCII"?>
<!-- This template is for creating an Internet Draft using xml2rfc,
     which is available here: http://xml.resource.org. -->
<!DOCTYPE rfc SYSTEM "rfc2629.dtd" [
<!-- One method to get references from the online citation libraries.
     There has to be one entity for each item to be referenced. 
     An alternate method (rfc include) is described in the references. -->
<!ENTITY RFC2119 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2119.xml">
<!ENTITY RFC2629 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2629.xml">
<!ENTITY RFC3552 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.3552.xml">
<!ENTITY I-D.narten-iana-considerations-rfc2434bis SYSTEM "http://xml.resource.org/public/rfc/bibxml3/reference.I-D.narten-iana-considerations-rfc2434bis.xml">
]>
<?xml-stylesheet type='text/xsl' href='rfc2629.xslt' ?>
<!-- used by XSLT processors -->
<!-- For a complete list and description of processing instructions (PIs), 
     please see http://xml.resource.org/authoring/README.html. -->
<!-- Below are generally applicable Processing Instructions (PIs) that most I-Ds might want to use.
     (Here they are set differently than their defaults in xml2rfc v1.32) -->
<?rfc strict="yes" ?>
<!-- give errors regarding ID-nits and DTD validation -->
<!-- control the table of contents (ToC) -->
<?rfc toc="yes"?>
<!-- generate a ToC -->
<?rfc tocdepth="4"?>
<!-- the number of levels of subsections in ToC. default: 3 -->
<!-- control references -->
<?rfc symrefs="yes"?>
<!-- use symbolic references tags, i.e, [RFC2119] instead of [1] -->
<?rfc sortrefs="yes" ?>
<!-- sort the reference entries alphabetically -->
<!-- control vertical white space 
     (using these PIs as follows is recommended by the RFC Editor) -->
<?rfc compact="yes" ?>
<!-- do not start each main section on a new page -->
<?rfc subcompact="no" ?>
<!-- keep one blank line between list items -->
<!-- end of list of popular I-D processing instructions -->
<rfc category="info" docName="draft-hunt-http-rest-redirect-00"
     ipr="trust200902">
  <!-- category values: std, bcp, info, exp, and historic
     ipr values: full3667, noModification3667, noDerivatives3667
     you can add the attributes updates="NNNN" and obsoletes="NNNN" 
     they will automatically be output with "(if approved)" -->

  <!-- ***** FRONT MATTER ***** -->

  <front>
    <!-- The abbreviated title is used in the page header - it is only necessary if the 
         full title is longer than 39 characters -->

    <title abbrev="draft-hunt-http-rest-redirect-00">HTTP Redirect Codes for
    RESTful Services</title>

    <!-- add 'role="editor"' below for the editors if appropriate -->

    <!-- Another author who claims to be an editor -->

    <author fullname="Phil Hunt" initials="P." role="editor" surname="Hunt">
      <organization>Oracle Corporation</organization>

      <address>
        <email>phil.hunt@yahoo.com</email>

        <!-- uri and facsimile elements may also be added -->
      </address>
    </author>

    <date month="January" year="2014"/>

    <!-- If the month and year are both specified and are the current ones, xml2rfc will fill 
         in the current day for you. If only the current year is specified, xml2rfc will fill 
	 in the current day and month for you. If the year is not the current one, it is 
	 necessary to specify at least a month (xml2rfc assumes day="1" if not specified for the 
	 purpose of calculating the expiry date).  With drafts it is normally sufficient to 
	 specify just the year. -->

    <!-- Meta-data Declarations -->

    <area>App</area>

    <workgroup>HTTPbis</workgroup>

    <!-- WG name at the upperleft corner of the doc,
         IETF is fine for individual submissions.  
	 If this element is not present, the default is "Network Working Group",
         which is used by the RFC Editor as a nod to the history of the IETF. -->

    <keyword>HTTP</keyword>

    <keyword>REST</keyword>

    <keyword>Redirect</keyword>

    <!-- Keywords will be incorporated into HTML output
         files in a meta tag but they have no effect on text or nroff
         output. If you submit your draft to the RFC Editor, the
         keywords will be used for the search engine. -->

    <abstract>
      <t>This specification clarifies the use of HTTP redirect codes when used
      with RESTful services.</t>
    </abstract>
  </front>

  <middle>
    <section title="Introduction">
      <t>Representational State Transfer or REST is an architectural style for
      networked systems as described in Dr. Roy Fieldings Ph.D. dissertation
      <xref target="Fielding-REST"/>. Though <xref target="Fielding-REST"/> is
      not dependant upon any particular protocol, this specfiction pertains to
      services built upon HTTP as defined by <xref target="RFC2616"/>
      hereafter called RESTful services. </t>

      <t>Section 10.3 of the HTTP specification defines several redirect
      response codes normally used to redirect user-agents (browsers) in
      response to HTTP requests. This specification clarifies the use of HTTP
      redirect code 307 (defined in <xref target="RFC2616"/>) and HTTP
      Redirect code 308 (as defined in <xref
      target="I-D.reschke-http-status-308"/>) with RESTful services.</t>

      <section title="Requirements Language">
        <t>The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
        "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
        document are to be interpreted as described in <xref
        target="RFC2119">RFC 2119</xref>.</t>
      </section>
    </section>

    <section anchor="RESTredirection" title="RESTful Redirection">
      <t>In order to preserve the integrity of REST operations, HTTP
      redirection codes 301-306 SHOULD NOT be used unless the service provider
      is aware the client is in fact a user-agent. Redirection code 301-306
      require clients to convert requests to HTTP GET or HEAD and are not
      normally suitable.</t>

      <t>REST servers MAY issue two types of HTTP redirects: HTTP redirect 307
      for temporary redirection and HTTP redirect 308 for permanent
      redirection.</t>

      <t>Upon receiving redirect code 307 OR 308, REST clients SHOULD preserve
      the HTTP request and the implied REST operation by applying the same
      request to the new resource location specified in the redirect.</t>

      <section title="Temporary Redirection">
        <t>A service provider MAY temporarily redirect clients using HTTP 307
        as specified in RFC2616. The original HTTP action MUST be
        preserved.</t>

        <t>The REST client MUST use the original permanent URI when
        referencing the affected REST resource in any other REST operations or
        REST resource.</t>

        <t>If there is no user-agent involved in the transaction, the REST
        client MAY proceed by automatically processing the redirect. Clients
        MUST ensure that the new location keeps the operation intent
        intact.</t>
      </section>

      <section title="Permanent Redirection">
        <t>In the event that a REST resource has been relocated or reassigned,
        a service provider MAY issue an HTTP 308 redirect. This redirect
        informs the REST client of the new permanent URI for the object.</t>

        <t>REST clients MUST ensure that the new address keeps the operation
        intent intact and the same HTTP verb is used.</t>

        <t>The REST client MUST use the new permanent URI when referencing the
        affected REST resource in any other REST operations or REST
        resource.</t>

        <t>If there is no user-agent involved in the transaction, the REST
        client MAY proceed by automatically processing the redirect.</t>
      </section>

      <section title="Alias Redirection">
        <t>REST based services MAY use HTTP redirection code 308 in order to
        permit aliasing of RESTful resources.</t>

        <t>Servers that DO NOT support REST resource aliases SHOULD respond
        with HTTP 404 (not found) if an alias request is received or is not
        otherwise resolvable.</t>

        <section title="Self Referencing Alias">
          <t>In situations where the client wishes to refer to the current
          security context of the user, the server MAY translate a URI of the
          form "&lt;server-prefix&gt;/me" to mean the resource represented by
          current authenticated subject where "&lt;server-prefix" is the URI
          fragment of the REST service root.</t>

          <t>If "&lt;server-prefix&gt;/me" does not resolve to a resource
          within the service endpoint requested, the service provider MUST
          respond with HTTP 404 (not found). If subject is resolved to a
          resource, the service provider MAY use HTTP 308 to redirect the SCIM
          client to the permanent URI of the authenticated subject.</t>
        </section>
      </section>
    </section>

    <section anchor="Acknowledgements" title="Acknowledgements">
      <t>This specification was developed based on discussions within the SCIM
      working group. The author would like to thank the members for their
      input.</t>
    </section>

    <!-- Possibly a 'Contributors' section ... -->

    <section anchor="IANA" title="IANA Considerations">
      <t>This memo includes no request to IANA.</t>
    </section>

    <section anchor="Security" title="Security Considerations">
      <t>All security considerations that applye to HTTP redirects as
      specified by <xref target="RFC2616"/>, apply to redirect 308.</t>
    </section>
  </middle>

  <!--  *****BACK MATTER ***** -->

  <back>
    <!-- References split into informative and normative -->

    <!-- There are 2 ways to insert reference entries from the citation libraries:
     1. define an ENTITY at the top, and use "ampersand character"RFC2629; here (as shown)
     2. simply use a PI "less than character"?rfc include="reference.RFC.2119.xml"?> here
        (for I-Ds: include="reference.I-D.narten-iana-considerations-rfc2434bis.xml")

     Both are cited textually in the same manner: by using xref elements.
     If you use the PI option, xml2rfc will, by default, try to find included files in the same
     directory as the including file. You can also define the XML_LIBRARY environment variable
     with a value containing a set of directories to search.  These can be either in the local
     filing system or remote ones accessed by http (http://domain/dir/... ).-->

    <references title="Normative References">
      <!--?rfc include="http://xml.resource.org/public/rfc/bibxml/reference.RFC.2119.xml"?-->

      <?rfc include='http://xml.resource.org/public/rfc/bibxml/reference.RFC.2616.xml'?>

      &RFC2119;
    </references>

    <references title="Informative References">
      <!-- Here we use entities that we defined at the beginning. -->

      <!-- A reference written by by an organization not a person. -->

      <?rfc include='http://xml.resource.org/public/rfc/bibxml3/reference.I-D.draft-reschke-http-status-308-07.xml'?>

      <reference anchor="Fielding-REST">
        <front>
          <title>"Architectural Styles and the Design of Network-based
          Software Architectures", Doctoral Dissertation, 2000.</title>

          <author fullname="Roy Fielding" initials="R." role="editor"
                  surname="Fielding">
            <organization/>
          </author>

          <date/>
        </front>
      </reference>
    </references>

    <!-- Change Log

v00 2014-01-15  PH    Initial version -->
  </back>
</rfc>
