lihaoyi / test

0 stars 0 forks source link

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

Open lihaoyi opened 1 month ago

lihaoyi commented 1 month ago

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. ID: 105 Original Author: andreak