Uploaded image for project: 'Undertow'
  1. Undertow
  2. UNDERTOW-2227

Response Body contains HTTP Status and headers

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • Major
    • None
    • 2.0.13.Final
    • Core, Servlet
    • None

    Description

      We have a JAX-RS endpoint deployed in Wildfly 14.0.1 which returns a simple JSON.

      Sometimes, the response body does not contain the JSON content, but the HTTP status and headers are written at the beginning of the response body.

      I'm going to clarify the problem with an example.

      This is the correct response stream:{}

      HTTP/1.1 200 OK 
      Connection: keep-alive 
      Content-Length: 156 
      Content-Type: application/json 
      Date: Tue, 10 Jan 2023 16:34:04 GMT  
      
      {"outcome":"0","description":"The service completed successfully","emsResult":{"outcomeCode":"0","outcomeDescription":"The service completed successfully"}}

      {}But sometimes this response is read:

      HTTP/1.1 200 OK 
      Connection: keep-alive 
      Content-Length: 156 
      Content-Type: application/json 
      Date: Tue, 10 Jan 2023 16:34:10 GMT  
      
      HTTP/1.1 200 OK 
      Connection: keep-alive 
      Content-Length: 156 
      Content-Type: application/json 
      Date: Tue, 10 Jan 2023 16:34:10 GMT
      mpleted successfully"}} 

      We verified the problem using tcpdump, in order to be sure that this is not a client reading problem, but the response above is actually produced by the server.

      It seems that when the response stream is written, the buffer is somehow reset and the body content is overwritten with the HTTP status and headers. Note that after the duplicated HTTP status and Headers there is the last part of the JSON.

      Thanks in advance.

       

       

      Attachments

        Activity

          People

            flaviarnn Flavia Rainone
            antonio.derrico@tasgroup.it Antonio D'Errico (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: