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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Request and Response types in OkResponseCache. #379

Merged
merged 1 commit into from
Dec 30, 2013

Conversation

swankjesse
Copy link
Collaborator

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.

@@ -237,7 +237,8 @@ public Builder addHeader(String name, String value) {
return this;
}

Builder rawHeaders(RawHeaders rawHeaders) {
// TODO: this shouldn't be public.
Copy link
Collaborator Author

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.

Choose a reason for hiding this comment

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

Understood. Growing pains :)

@codefromthecrypt
Copy link

I support this change and agree with the rationale.

? entry.handshake.localCertificates()
: null;
@Override public long contentLength() {
return contentLength != null ? Long.parseLong(contentLength) : -1;
Copy link
Collaborator

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.

Copy link
Collaborator Author

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.

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.
JakeWharton added a commit that referenced this pull request Dec 30, 2013
Use Request and Response types in OkResponseCache.
@JakeWharton JakeWharton merged commit 63a278d into master Dec 30, 2013
@JakeWharton JakeWharton deleted the jwilson/new_cache_api branch December 30, 2013 00:06
@JakeWharton
Copy link
Collaborator

Lots of good red code in this diff!

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.

4 participants