Uploaded image for project: 'Spring Web Services'
  1. Spring Web Services
  2. SWS-583

AbstractHttpSenderConnection does not immediately recognise HTTP 204 has no content-length


    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.5.8
    • Fix Version/s: 1.5.9
    • Component/s: Core
    • Labels:


      The hasResponse() method in AbstractHttpSenderConnection currently only has specific logic for the HTTP 202 status code, immediately returning false. If a 204 is received without the Conent-Length header set (not mandatory as by definition a 204 has no content), the method will go straight to inferring the content-length by trying to read the input stream. The input stream will not contain any content and so it is left to the client server's keepAliveTimeout value to close the stream and cause the method to finish.

      Although the correct result is returned from the method, it would be much better if there was a simple check for the 204 status to return false straight away.

      This caused issues with our system as our sending method which uses the WebServiceTemplate took 20 seconds to finish even though the HTTP 204 was received within a few ms (the 20 seconds was configured on the client's server).

      The first if statement in the current method could be adapted (with a new STATUS_NO_CONTENT added to the HttpTransportConstants representing 204):

       protected final boolean hasResponse() throws IOException {
              if (HttpTransportConstants.STATUS_ACCEPTED == getResponseCode()) {
                  return false;
              long contentLength = getResponseContentLength();
              if (contentLength < 0) {
                  if (responseBuffer == null) {
                      responseBuffer = FileCopyUtils.copyToByteArray(getRawResponseInputStream());
                  contentLength = responseBuffer.length;
              return contentLength > 0;


        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open In Progress In Progress
        54d 4h 23m 1 Arjen Poutsma 06/Jan/10 12:36 AM
        In Progress In Progress Resolved Resolved
        3m 18s 1 Arjen Poutsma 06/Jan/10 12:40 AM
        Resolved Resolved Closed Closed
        849d 6h 23m 1 Arjen Poutsma 04/May/12 7:03 AM


          • Assignee:
            arjen.poutsma Arjen Poutsma
            rubrica Adam Healey
          • Votes:
            0 Vote for this issue
            0 Start watching this issue


            • Created:

              Time Tracking

              Original Estimate - Not Specified
              Not Specified
              Remaining Estimate - 0d
              Time Spent - 0.2h