Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Header redesign proposal #4415

Merged
merged 118 commits into from Feb 26, 2021
Merged

Header redesign proposal #4415

merged 118 commits into from Feb 26, 2021

Conversation

SystemFw
Copy link
Member

[A: Header] 馃憤 , HeaderT#Value 馃憥

Copy link
Member

@rossabaker rossabaker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks highly promising!

core/src/main/scala/org/http4s/HeaderV2.scala Outdated Show resolved Hide resolved
core/src/main/scala/org/http4s/HeaderV2.scala Outdated Show resolved Hide resolved
*
* - A value of type `A` which has a `Header[A]` in scope
* - A (name, value) pair of `String`, which is treated as a `Recurring` header
* - A `Header.Raw`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be a great place for an inline example.

core/src/main/scala/org/http4s/HeaderV2.scala Outdated Show resolved Hide resolved
core/src/main/scala/org/http4s/HeaderV2.scala Show resolved Hide resolved
core/src/main/scala/org/http4s/HeaderV2.scala Outdated Show resolved Hide resolved
core/src/main/scala/org/http4s/HeaderV2.scala Outdated Show resolved Hide resolved
core/src/main/scala/org/http4s/HeaderV2.scala Outdated Show resolved Hide resolved
* @param key name of the header to find
* @return a scala.Option possibly containing the resulting [[org.http4s.Header]]
*/
def get(key: CIString): Option[NonEmptyList[Header.Raw]] = headers.filter(_.name == key).toNel
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be simpler to just return List[Header.Raw]?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some reason I like Option[NonEmptyList here, I think the emphasis is more on the fact that the header might not be present, and I'd imagine you'd want to do a bunch of getOrElse, whereas it's not as easy to do onEmpty on List. Certainly up for debate though. Also the typed get returns Option[NonEmptyList[A]] for recurring headers, so there's some consistency there

@cquiroz
Copy link
Member

cquiroz commented Feb 15, 2021

This is looking great, we have had this pending for a really long time

case _ => F.pure(None)
else nope
case _ =>
req.headers.get(CIString("Range")) match {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is where I'm thinking the Select machinery returning an Ior might carry some weight. We have to handle headers that just vanish because they're invalid.

@rossabaker rossabaker marked this pull request as ready for review February 26, 2021 14:53
@rossabaker rossabaker merged commit eedbd60 into http4s:series/0.22 Feb 26, 2021
rossabaker added a commit to http4s/http4s-servlet that referenced this pull request Apr 3, 2022
rossabaker added a commit to http4s/http4s-servlet that referenced this pull request Apr 4, 2022
armanbilge pushed a commit to http4s/http4s-boopickle that referenced this pull request May 2, 2022
armanbilge pushed a commit to http4s/http4s-play-json that referenced this pull request May 2, 2022
armanbilge pushed a commit to http4s/http4s-scalatags that referenced this pull request May 2, 2022
armanbilge pushed a commit to http4s/http4s-twirl that referenced this pull request May 2, 2022
armanbilge pushed a commit to http4s/http4s-async-http-client that referenced this pull request May 20, 2022
armanbilge pushed a commit to http4s/http4s-jetty-client that referenced this pull request May 20, 2022
armanbilge pushed a commit to http4s/http4s-okhttp-client that referenced this pull request May 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants