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
(v6.4.14#64029)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to