Skip to content

Three tests in ServerFilesTests failing with Akka HTTP 10.5+ #4702

Closed
@honzabazant

Description

@honzabazant

Situation:

  • Our company obtained license from Lightbend so that we can use the latest Akka libraries
  • We are using Tapir and Scala 3 and we build our version of tapir-akka-http-server for Scala 3 with the latest Akka
  • As part of build, we run tests in the tapir-akka-http-server project to verify that our changes work.

Problem:
The following three tests in ServerFilesTests fail since Akka HTTP 10.5:

  • should return acceptRanges for file head request
  • should handle ranged HEAD request like a GET request
  • should return acceptRanges for resource head request

The reason is that these tests expect the Content-Length header to be returned, but Akka HTTP does not return it for HEAD requests anymore (see akka/akka-http#4214).

According to RFC, this behaviour seems to be valid:

A server MAY send a Content-Length header field in a response to a HEAD request (Section 9.3.2); a server MUST NOT send Content-Length in such a response unless its field value equals the decimal number of octets that would have been sent in the content of a response if the same request had used the GET method.

Our workaround is easy (we just comment out the failing assertions), but I wonder if these assertions could be changed to match the RFC so that:

  • if the Content-Length header is not present in the response, it is fine
  • if the header is present, its value must match expectation.

Thank you

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions