-
Notifications
You must be signed in to change notification settings - Fork 786
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compile without fatal warnings on 2.13.0 #2891
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,12 +6,13 @@ import cats.implicits._ | |
import cats.effect.IO | ||
import fs2.{Pure, Stream} | ||
import fs2.text.{utf8Decode, utf8Encode} | ||
import java.io.File | ||
import java.io.{File, Serializable} | ||
import java.net.{InetAddress, InetSocketAddress} | ||
import org.http4s.headers._ | ||
import org.http4s.util.decode | ||
import org.log4s.getLogger | ||
import _root_.io.chrisdavenport.vault._ | ||
import scala.util.hashing.MurmurHash3 | ||
|
||
/** | ||
* Represents a HTTP Message. The interesting subclasses are Request and Response. | ||
|
@@ -236,14 +237,14 @@ object Message { | |
* @param body fs2.Stream[F, Byte] defining the body of the request | ||
* @param attributes Immutable Map used for carrying additional information in a type safe fashion | ||
*/ | ||
sealed abstract case class Request[F[_]]( | ||
method: Method = Method.GET, | ||
uri: Uri = Uri(path = "/"), | ||
httpVersion: HttpVersion = HttpVersion.`HTTP/1.1`, | ||
headers: Headers = Headers.empty, | ||
body: EntityBody[F] = EmptyBody, | ||
attributes: Vault = Vault.empty | ||
) extends Message[F] { | ||
final class Request[F[_]]( | ||
val method: Method = Method.GET, | ||
val uri: Uri = Uri(path = "/"), | ||
val httpVersion: HttpVersion = HttpVersion.`HTTP/1.1`, | ||
val headers: Headers = Headers.empty, | ||
val body: EntityBody[F] = EmptyBody, | ||
val attributes: Vault = Vault.empty | ||
) extends Message[F] with Product with Serializable { | ||
import Request._ | ||
|
||
type Self = Request[F] | ||
|
@@ -414,6 +415,34 @@ sealed abstract case class Request[F[_]]( | |
override def toString: String = | ||
s"""Request(method=$method, uri=$uri, headers=${headers.redactSensitive()})""" | ||
|
||
override def hashCode(): Int = MurmurHash3.productHash(this) | ||
|
||
override def equals(that: Any): Boolean = (this eq that.asInstanceOf[Object]) || (that match { | ||
case that: Request[_] => | ||
(this.method == that.method) && | ||
(this.uri == that.uri) && | ||
(this.httpVersion == that.httpVersion) && | ||
(this.headers == that.headers) && | ||
(this.body == that.body) && | ||
(this.attributes == that.attributes) | ||
case _ => false | ||
}) | ||
|
||
def canEqual(that: Any) = that.isInstanceOf[Request[F]] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That |
||
|
||
def productArity: Int = 6 | ||
|
||
def productElement(n: Int) = n match { | ||
case 0 => method | ||
case 1 => uri | ||
case 2 => httpVersion | ||
case 3 => headers | ||
case 4 => body | ||
case 5 => attributes | ||
case _ => throw new IndexOutOfBoundsException() | ||
} | ||
|
||
override def productPrefix: String = "Request" | ||
} | ||
|
||
object Request { | ||
|
@@ -433,7 +462,10 @@ object Request { | |
headers = headers, | ||
body = body, | ||
attributes = attributes | ||
) {} | ||
) | ||
|
||
def unapply[F[_]](request: Request[F]): Option[(Method, Uri, HttpVersion, Headers, EntityBody[F], Vault)] = | ||
Some((request.method, request.uri, request.httpVersion, request.headers, request.body, request.attributes)) | ||
|
||
final case class Connection(local: InetSocketAddress, remote: InetSocketAddress, secure: Boolean) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a huge fan of these interfaces, but:
Product
makes hash code easier and was there before.Serializable
. I don't judge.