hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Artem Nakonechnyy (JIRA)" <j...@apache.org>
Subject [jira] [Created] (HTTPCLIENT-1860) Simplify pre-status-line garbage rejection config
Date Wed, 28 Jun 2017 18:02:00 GMT
Artem Nakonechnyy created HTTPCLIENT-1860:

             Summary: Simplify pre-status-line garbage rejection config
                 Key: HTTPCLIENT-1860
                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1860
             Project: HttpComponents HttpClient
          Issue Type: Improvement
            Reporter: Artem Nakonechnyy
         Attachments: LeadingGarbageLimiter.java

I'm building HttpClient via HttpClientBuilder, version is httpclient-4.5.3.jar.

By default there is no limit on the amount of garbage before status line (see DefaultHttpResponseParser#reject).
I'd like to set one: no more than X lines.
The documentation tells I'm to provide custom DefaultHttpResponseParser. So far so good: I'm
just to override one method. But to plug my DefaultHttpResponseParser in I have to do a lot
of things. I have to instantiate/configure/provide (hereinafter "deal with") a handful of
other objects. Specifically:
- I have to implement my HttpMessageParserFactory that returns my DefaultHttpResponseParser,
for that I also have to provide LineParser and HttpResponseFactory.
- then I create ManagedHttpClientConnectionFactory that returns my HttpMessageParserFactory

- then I create PoolingHttpClientConnectionManager where I put ManagedHttpClientConnectionFactory.
And for that I also have to deal with Registry<ConnectionSocketFactory>, PublicSuffixMatcher,
HostnameVerifier, SSLConnectionSocketFactory, SchemePortResolver, DnsResolver; plus timeToLive
config property
- also I have not to forget to set the same publicSuffixMatcher to HttpClientBuilder, as it's
used not only for ConnectionManager configuration

The full required code is attached (LeadingGarbageLimiter.java).

Not only that's hard, but having to deal with so much of stuff my code becomes more fragile
to potential API changes.

As an API client I'd very much appreciate some single-line config for such simple tweak as
the limit we're talking about.
I'd propose to add {{int maxGarbageBeforeStatusLine}} to MessageConstraints, it naturally
fits there along to the existing {{maxLineLength}} and {{maxHeaderCount}} settings.
And then use the new setting in DefaultHttpResponseParser.
Then all a client would have to do is {{HttpClientBuilder.create().setMaxGarbageBeforeStatusLine(X)}}.

This message was sent by Atlassian JIRA

To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org

View raw message