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

Issue #5171 Simplify GzipHandler user-agent handling #5196

Merged

Conversation

gregw
Copy link
Contributor

@gregw gregw commented Aug 24, 2020

Issue #5171 Simplify GzipHandler user-agent handling:

  • Remove User-Agent handling from GzipHandler
  • Allow Vary header to be set
  • Create rewrite MsieRule to remove Accept-Encoding from IE<=6

Signed-off-by: Greg Wilkins gregw@webtide.com

+ Remove User-Agent handling from GzipHandler
+ Allow Vary header to be set
+ Create rewrite MsieRule to remove Accept-Encoding from IE<=6

Signed-off-by: Greg Wilkins <gregw@webtide.com>
@gregw gregw requested a review from joakime August 24, 2020 15:13
@gregw gregw added this to the 10.0.x milestone Aug 24, 2020
@gregw gregw added this to To Do in Jetty 10.0.0 via automation Aug 24, 2020
@gregw gregw linked an issue Aug 24, 2020 that may be closed by this pull request
@gregw gregw requested a review from sbordet August 24, 2020 15:13
* passed. If the value needs to be merged with existing values,
* then a new field is created.
*/
public void ensure(HttpField field)
Copy link
Contributor

Choose a reason for hiding this comment

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

The semantic of this method is weird because not only ensures that a field exists, but also coalesces multiple fields into one - it should be clearly stated in the javadocs. Perhaps rename to ensureSingle()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've gone with ensureField to match computeField

computeField(field.getHeader(), (h, l) -> computeEnsure(field, field.getValues(), l));
else
computeField(field.getName(), (h, l) -> computeEnsure(field, field.getValues(), l));
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand this logic.
The first if says "if the given field is single-valued"; but then computeEnsure() is passed the field, and there is no need to have two different computeEnsure(), the second with the values extracted from the field that is passed as first parameter 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The implementation of the single field and multiple field versions are a bit different. Single field can already exist or not. Multi valued might partially exist.
I could simplify a ensureField a little, but only at the expense of complicating the computeEnsure methods.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note that I now have 100% test coverage of ensureField and both computeEnsure.

private static final int IEv6 = '6';
private static final Trie<Boolean> __IE6_BadOS = new ArrayTernaryTrie<>();
private static final HttpField CONNECTION_CLOSE = new HttpField(HttpHeader.CONNECTION, HttpHeaderValue.CLOSE);
public static final HttpField VARY_USER_AGENT = new PreEncodedHttpField(HttpHeader.VARY, HttpHeader.USER_AGENT.asString());
Copy link
Contributor

Choose a reason for hiding this comment

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

Does it need to be public?

}
return null;
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Unnecessary empty line.

Jetty 10.0.0 automation moved this from To Do to In Review Aug 26, 2020
@gregw gregw requested a review from sbordet August 26, 2020 14:45
@gregw gregw merged commit 601710c into jetty-10.0.x Aug 26, 2020
Jetty 10.0.0 automation moved this from In Review to Done Aug 26, 2020
@gregw gregw deleted the jetty-10.0.x-5171-simplify-user-agent-gzip-handling branch August 26, 2020 21:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Jetty 10.0.0
  
Done
Development

Successfully merging this pull request may close these issues.

GzipHandler Vary head should be configurable
2 participants