-
Notifications
You must be signed in to change notification settings - Fork 9.2k
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
Use Request and Response types in OkResponseCache. #379
Conversation
@@ -237,7 +237,8 @@ public Builder addHeader(String name, String value) { | |||
return this; | |||
} | |||
|
|||
Builder rawHeaders(RawHeaders rawHeaders) { | |||
// TODO: this shouldn't be public. |
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.
This is the trickiest part of this change. I think I'll be able to fix this in a follow-up by using Request + Response more internally in HttpEngine. The tricky part of that change is that Request + Response are immutable, but the classes in use now (RequestHeaders, ResponseHeaders) are mutable.
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.
Understood. Growing pains :)
I support this change and agree with the rationale. |
? entry.handshake.localCertificates() | ||
: null; | ||
@Override public long contentLength() { | ||
return contentLength != null ? Long.parseLong(contentLength) : -1; |
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.
This still has the potential to throw on a malformed header, right? The response is persisted to the cache as-is.
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.
Yup, good catch. Fixed to try/catch and return -1. In follow up I'll try to find a way to share the ResponseHeaders parser here.
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.
Nice catch, Jake.
This breaks support for java.net.ResponseCache implementations. That's good. That API is akward and can't support important features like conditional GETs and hit tracking.
Use Request and Response types in OkResponseCache.
Lots of good red code in this diff! |
This breaks support for java.net.ResponseCache implementations. That's
good. That API is akward and can't support important features like
conditional GETs and hit tracking.