requests-scala icon indicating copy to clipboard operation
requests-scala copied to clipboard

Exception in Requester.stream when response is 304, where response-header doesn't include "location"

Open andreak opened this issue 2 years ago • 0 comments

Using version 0.7.0 When receiving 304 "not modified" this code throws NoSuchElementException:

        if (responseCode.toString.startsWith("3") && maxRedirects > 0){
          val out = new ByteArrayOutputStream()
          Util.transferTo(connection.getInputStream, out)
          val bytes = out.toByteArray

          val current = Response(
            url,
            responseCode,
            responseMsg,
            new geny.Bytes(bytes),
            headerFields,
            redirectedFrom
          )
          persistCookies()
          val newUrl = current.headers("location").head

On line 309 val newUrl = current.headers("location").head Sending location in 304 response is not required.

andreak avatar May 01 '22 13:05 andreak