Uploaded image for project: 'RESTEasy'
  1. RESTEasy
  2. RESTEASY-3019

Content-Length header value with leading whitespaces causes Exception

    XMLWordPrintable

Details

    Description

      When receiving a (multipart-formdata POST) request with the content-length header value set with a whitespace before the actual length-value RESTEasy throws the below exception and fails to process the request.
      As stated in RFC7230 (https://datatracker.ietf.org/doc/html/rfc7230#section-3.2.3) whitespaces are valid and should thus be correctly processed (trimmed).

      java.lang.NumberFormatException: For input string: " 896"
      at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
      at java.lang.Long.parseLong(Long.java:578)
      at java.lang.Long.parseLong(Long.java:631)
      at org.jboss.resteasy.util.NoContent.isContentLengthZero(NoContent.java:32)
      at org.jboss.resteasy.plugins.providers.StringTextStar.readFrom(StringTextStar.java:41)
      at org.jboss.resteasy.plugins.providers.StringTextStar.readFrom(StringTextStar.java:24)
      at org.jboss.resteasy.plugins.providers.multipart.MultipartInputImpl$PartImpl.getBody(MultipartInputImpl.java:344)
      at org.jboss.resteasy.plugins.providers.multipart.MultipartInputImpl$PartImpl.getBodyAsString(MultipartInputImpl.java:39)
      

      Attachments

        Activity

          People

            rsearls r searls
            klingebos Frank Klingebiel (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: