zio / zio-http

A next-generation Scala framework for building scalable, correct, and efficient HTTP clients and servers
https://zio.dev/zio-http
Apache License 2.0
768 stars 389 forks source link

Encoder should strip fragments on request. #2446

Closed brycechesternewman closed 1 week ago

brycechesternewman commented 11 months ago

Describe the bug Sometimes URI's returned from the HTTP header "Location" contain a fragment. Applies to "dev.zio" %% "zio-http" % "3.0.0-RC2".

To Reproduce Steps to reproduce the behaviour:

  1. Sometimes URI's returned from the HTTP header "Location" contain a fragment. i.e.http:///?dl=1#
  2. Using ZClient..request(Version.HTTP/1.1, Method.GET, "http:///?dl=1#", Headers.empty, Body.empty, client.sslConfig)
  3. Remote server returns 400 error since the fragment is not expected.

Expected behaviour Encoder should strip fragments on request. NettyRequestEncoder.encode appears to be the location the fragments should be stripped. The workaround for us now is to manually strip those fragments vis url.copy(fragments = None).

Screenshots n/a/

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context

brycechesternewman commented 2 months ago

Hello. This is still an issue in 3.0.0-RC6 and now we can't remove fragments using ZClientAspect.followRedirects(...). We can't currently use ZClientAspect.followRedirects(...), so reverted to our own retry of redirects. We should be able to access the redirect URI. Quite honestly this is I think an issue with how DropBox creates shared URI's though the web UI. DropBox does not include fragments if we use the API, but that is not an option for now.

987Nabil commented 2 months ago

Thanks for letting us know that it is still broken. I have a few features that should go in before 3.0. After that bug fixing is prio no 1. We will take a look at this issue then for sure too.