Struts 2
  1. Struts 2
  2. WW-3303

allow POST, PUT or DELETE to return content

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.3.18
    • Fix Version/s: 2.3.1
    • Component/s: Plugin - REST
    • Labels:
      None
    • Environment:

      this problem involve any environment

      Description

      currently return a content from a request using POST, PUT or DELETE method is explicit ignored by DefaultContentTypeHandlerManager:
      // Don't return any content for PUT, DELETE, and POST where there are no errors
      if (!statusNotOk && !"get".equalsIgnoreCase(req.getMethod()))

      { target = null; } many time expecially in ajax application that use restful webservice endpoints required that returned content from those request had some information. This help client to reduce the network usage. So the client don't need to do 2 request to update a content and retrive updated content. for instance DELETE /items/1 can responde with information usegul to the client: { movingTo: "/archived-items/1", status: "archiving" }

      in general would be responsability of protocol implementation chose right content to return back to the client. Or in other world developer need to have freedom to chose to return back a content or not.

      to complete the description of this issue i report here some excerpt of HTTP 1.1 specification where is described that those method request should return a content (see http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.5):

      • POST, "The action performed by the POST method might not result in a resource that can be identified by a URI. In this case, either 200 (OK)_ or 204 (No Content) is the appropriate response status, depending on whether or not the response includes an entity that describes the result."
      • PUT, rfc do not explicit disallow returning a content
      • DELETE, "A successful response SHOULD be 200 (OK) if the response includes an entity describing the status, 202 (Accepted) if the action has not yet been enacted, or 204 (No Content) if the action has been enacted but the response does not include an entity. "

        Issue Links

          Activity

          Luca Marrocco created issue -
          Luca Marrocco made changes -
          Field Original Value New Value
          Attachment allow-content-for-POST-PUT-DELETE.patch [ 14137 ]
          Jeff Turner made changes -
          Project Import Mon Feb 01 01:17:42 UTC 2010 [ 1264987062082 ]
          Lukasz Lenart made changes -
          Affects Version/s 2.3.x [ 12319176 ]
          Affects Version/s 2.2.x [ 12314679 ]
          Lukasz Lenart made changes -
          Link This issue is a clone of WW-3713 [ WW-3713 ]
          Lukasz Lenart made changes -
          Status Open [ 1 ] Closed [ 6 ]
          Fix Version/s 2.3.1 [ 12315916 ]
          Resolution Fixed [ 1 ]

            People

            • Assignee:
              Unassigned
              Reporter:
              Luca Marrocco
            • Votes:
              1 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development