Commit Graph

341 Commits

Author SHA1 Message Date
dirkhenselin 8151d9e51a Avoid updating Content-Length header in a 304 response.
I observed the following problem: `Transfer-Encoding` and
`Content-Length` headers should be mutually exclusive and because I use
chunked transfer, the `Transfer-Encoding` header is set in the response
while the `Content-Length` header is not. In case of a 304 during a
revalidation, the header contains Content-Length=0. Probably a proxy is
responsible for this, just like the comment "Some well-known proxies
respond with Content-Length=0, when returning 304" in the method
CachedHttpResponseGenerator::addMissingContentLengthHeader is saying. In
CacheEntryUpdater::mergeHeaders the Content-Length=0 is merged into the
cached entry, but the cached entry contains also a `Transfer-Encoding`
header, so in the cached entry these headers aren't mutually exclusive
anymore. Because of the `Transfer-Encoding` header the method
CachedHttpResponseGenerator::addMissingContentLengthHeader isn't fixing
the `Content-Length` header and Content-Length=0 causes returning null
instead of the cached content. IMHO the `Content-Length` header should
not be merged into the cached response in case of a 304, at least if the
cached entry contains a `Transfer-Encoding` header.
2020-10-03 12:30:11 +02:00
Olof Larsson 3d09a43008 HTTPCLIENT-2023: Allow nested arrays and all primitive types in DefaultHttpCacheEntrySerializer 2019-11-08 09:47:55 +01:00
Olof Larsson 4a354148f0 HTTPCLIENT-2022: Use message parameter in HttpCacheEntrySerializationException constructor 2019-11-06 18:39:21 +01:00
Artem Smotrakov c8068487fb HTTPCLIENT-1976: Unsafe deserialization in DefaultHttpCacheEntrySerializer 2019-04-02 12:16:03 +02:00
Oleg Kalnichevski 2004eef668 HTTPCLIENT-1968: Preserve escaped PATHSAFE characters when normalizing URI path segments 2019-02-16 13:22:40 +01:00
Oleg Kalnichevski 4a463ebf4e URI normalization code to use URLEncodedUtils#parsePathSegments method to split path segments 2019-02-16 13:06:07 +01:00
Oleg Kalnichevski 030dbffe17 Improved cache key generation (ported from HttpCore master) 2019-02-16 12:02:15 +01:00
Tamas Cservenak 4093a3015d HTTPCLIENT-1968: Make normalization of URI paths optional
Make it driven by RequestConfig.
2019-02-16 11:50:11 +01:00
Jayson Raymond d150f5abae Some well known proxies respond with Content-Length=0, when returning 304. For robustness, always use the cached entity's content length, as modern browsers do. 2019-02-07 19:15:52 +01:00
Oleg Kalnichevski c04ffa17ce Added missing @deprecated javadoc tags; fixed style check violations 2018-11-03 11:34:35 +01:00
Gary Gregory e6c226d5f6 - Always use blocks
- Add missing serial version ID (default 1L)
- Camel-case names.
- Don't nest in else clause unnecessarily.
- Remove declared exceptions that are not thrown (but don't break BC.)
- Remove redundant superinterface
- Access static methods directly
- Better local var names.
2018-08-14 20:54:41 +02:00
Sudheera Palihakkara 0593c591ad HTTPCLIENT-1690: Updated a test case 2018-01-15 18:31:00 +08:00
Sudheera Palihakkara f1f3a38763 HTTPCLIENT-1690: Avoid merging Content-Encoding headers coming with 304 status to cache entry, port mergeHeaders method from master 2018-01-15 10:00:03 +01:00
Oleg Kalnichevski cfbbea0ee3 Fixed NPE in case of a missing Max-Forwards header 2017-10-16 13:49:31 +02:00
Gary Gregory 61529d1f88 Checkstyle fixes: Use final and tab police. 2017-07-12 17:29:17 -07:00
Leandro Nunes dac57c57f6 Closes PR #77
Avoid fetching the cached entity twice on cache hit.
2017-05-29 21:14:36 +02:00
Leandro Nunes 10ab37b775 Removing unnecessary checks for cache invalidation calls. 2017-05-18 15:12:05 +01:00
Oleg Kalnichevski 90fd3936da Better handling of missing content-type header in OPTIONS with entity
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/branches/4.6.x@1787697 13f79535-47bb-0310-9956-ffa450edef68
2017-05-13 11:13:36 +02:00
Oleg Kalnichevski 61bf8ba35e fix cache NFE for big content length
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/branches/4.5.x@1790037 13f79535-47bb-0310-9956-ffa450edef68
2017-05-13 11:08:37 +02:00
Gary D. Gregory 4aa07e6c51 Add missing '@Override' annotations.
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/branches/4.5.x@1788707 13f79535-47bb-0310-9956-ffa450edef68
2017-05-13 11:07:09 +02:00
Oleg Kalnichevski 0514407d8c Upgraded HttpCore to version 4.4.5
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/branches/4.5.x@1770506 13f79535-47bb-0310-9956-ffa450edef68
2016-11-19 16:40:54 +00:00
Gary D. Gregory 9d5dde271f Add final modifier to private fields.
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/branches/4.5.x@1726967 13f79535-47bb-0310-9956-ffa450edef68
2016-01-27 09:00:25 +00:00
Oleg Kalnichevski 95754d776c HTTPCLIENT-1244: convert unit tests for cache module to use Mockito
Contributed by Joseph Walton <joe at kafsemo dot org>

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1661658 13f79535-47bb-0310-9956-ffa450edef68
2015-02-23 12:42:47 +00:00
Oleg Kalnichevski 1964e9530a HTTPCLIENT-1575: Disallow HttpRoute instances with default (-1) port
Contributed by Joseph Walton <joe at kafsemo.org>

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1638138 13f79535-47bb-0310-9956-ffa450edef68
2014-11-11 15:09:48 +00:00
Francois-Xavier Bonnet 0cedb7c8cc HTTPCLIENT-1515: Caching responses to HEAD requests
Fixed API change and removed opt-in parameter

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1637599 13f79535-47bb-0310-9956-ffa450edef68
2014-11-08 21:47:12 +00:00
Francois-Xavier Bonnet 2883531e92 Merge remote-tracking branch 'J-Cutajar/cache-head-responses' into trunk
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1637389 13f79535-47bb-0310-9956-ffa450edef68
2014-11-07 15:23:03 +00:00
Gary D. Gregory 224711a6d1 Javadoc 8 fixes.
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1619450 13f79535-47bb-0310-9956-ffa450edef68
2014-08-21 15:44:19 +00:00
Gary D. Gregory fb374dab5f Javadoc 8 fixes: Use {@code foo} instead of <code>foo</foo>.
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1619429 13f79535-47bb-0310-9956-ffa450edef68
2014-08-21 15:09:04 +00:00
Oleg Kalnichevski 1894418915 HTTPCLIENT-1542: Caching HttpClient uses absolute URIs for validation (follow-up patch, more tests)
Based on contribution by Joseph Walton <joe at kafsemo.org>

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1618558 13f79535-47bb-0310-9956-ffa450edef68
2014-08-18 07:55:10 +00:00
Oleg Kalnichevski 683bb070fd HTTPCLIENT-1542: Caching HttpClient uses absolute URIs for validation
Based on contribution by Joseph Walton <joe at kafsemo.org>

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1618324 13f79535-47bb-0310-9956-ffa450edef68
2014-08-16 10:51:35 +00:00
Sebastian Bazley 4006d7e4f2 Add TODOs for code that needs looking at
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1604892 13f79535-47bb-0310-9956-ffa450edef68
2014-06-23 17:46:29 +00:00
Oleg Kalnichevski 2ebd820284 Migrated integration tests to HttpServer from HttpCore 4.4
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1603443 13f79535-47bb-0310-9956-ffa450edef68
2014-06-18 13:06:43 +00:00
Oleg Kalnichevski b3b1b712df Cleanups in CachingExec and related test classes
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1572556 13f79535-47bb-0310-9956-ffa450edef68
2014-02-27 13:32:58 +00:00
Oleg Kalnichevski 29e692e410 Made AsynchronousValidationRequest public
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1571715 13f79535-47bb-0310-9956-ffa450edef68
2014-02-25 14:46:07 +00:00
Oleg Kalnichevski 013ed18c5c Code cleanups
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1571714 13f79535-47bb-0310-9956-ffa450edef68
2014-02-25 14:45:14 +00:00
Sebastian Bazley 33b4fc1db7 Javadoc
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1571527 13f79535-47bb-0310-9956-ffa450edef68
2014-02-25 01:54:35 +00:00
Sebastian Bazley d90f21400f Suppress unused warnings for ctor tests
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1571526 13f79535-47bb-0310-9956-ffa450edef68
2014-02-25 01:53:36 +00:00
Sebastian Bazley 79c90bd159 Oops - Cannot use top level EasyMock for everything.
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1571432 13f79535-47bb-0310-9956-ffa450edef68
2014-02-24 20:46:49 +00:00
Sebastian Bazley 4908990207 Explicit boxing
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1571423 13f79535-47bb-0310-9956-ffa450edef68
2014-02-24 20:16:48 +00:00
Sebastian Bazley 7eb9097b1c Rename or inline local variables to avoid variable hiding
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1571416 13f79535-47bb-0310-9956-ffa450edef68
2014-02-24 19:54:01 +00:00
Sebastian Bazley 036e717655 We don't need the content length as an int; avoid the boxing
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1571393 13f79535-47bb-0310-9956-ffa450edef68
2014-02-24 18:48:09 +00:00
Sebastian Bazley 0b7d6186db Boxing not usually important in test code; the EasyMock classes generate a lot of warnings
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1571383 13f79535-47bb-0310-9956-ffa450edef68
2014-02-24 18:28:17 +00:00
Sebastian Bazley 7e162182b3 Boxing not usually important in test code; the EasyMock classes generate a lot of warnings
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1571382 13f79535-47bb-0310-9956-ffa450edef68
2014-02-24 18:24:25 +00:00
Sebastian Bazley eaaa6fc3ed Avoid name hiding
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1571377 13f79535-47bb-0310-9956-ffa450edef68
2014-02-24 18:16:15 +00:00
Sebastian Bazley fe360e7b3d Rename or inline local variables to avoid variable hiding
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1571371 13f79535-47bb-0310-9956-ffa450edef68
2014-02-24 18:03:43 +00:00
Sebastian Bazley 722f5c256b Remove unnecessary duplicate field setup
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1571365 13f79535-47bb-0310-9956-ffa450edef68
2014-02-24 17:30:56 +00:00
Sebastian Bazley c06d7ae10c Avoid name hiding
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1571364 13f79535-47bb-0310-9956-ffa450edef68
2014-02-24 17:30:30 +00:00
Sebastian Bazley 896fa04ce3 Remove unnecessary duplicate field setup
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1571361 13f79535-47bb-0310-9956-ffa450edef68
2014-02-24 17:25:19 +00:00
Sebastian Bazley defc45ca50 Remove unnecessary duplicate field setup and rename variable to avoid hiding
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1571360 13f79535-47bb-0310-9956-ffa450edef68
2014-02-24 17:22:50 +00:00
Sebastian Bazley eddeaa64e6 Avoid warnings: the static method should be accessed directly
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1571346 13f79535-47bb-0310-9956-ffa450edef68
2014-02-24 16:49:54 +00:00