Commit Graph

3702 Commits

Author SHA1 Message Date
Arturo Bernal 5f6d370ccd HTTPCLIENT-1920: Add a check in CachedResponseSuitabilityChecker to ensure that cache entries created by HEAD requests are not used to serve GET requests. 2023-12-13 11:54:39 +01:00
Arturo Bernal b9e2bbc778 Add Last-Modified header to 304 response when ETag is not present
.

This commit adds the Last-Modified header to the 304 Not Modified response when the ETag header is not present in the cache entry. This aligns the behavior with the recommendations in RFC 7232 and helps clients that rely on the Last-Modified header for cache updates when
2023-12-13 11:54:39 +01:00
Arturo Bernal e1cfb2add6 Complete the implementation of stale-if-error support as per RFC 5861
- Updated handling of IOExceptions to serve stale responses when allowed by stale-if-error
2023-12-13 11:54:39 +01:00
Arturo Bernal 7bf84b71d4 Extend stale-if-error to apply to non-revalidatable cache entries.
The stale-if-error Cache-Control directive is used to indicate that a cached response can be used to satisfy a request even when an error occurs, as long as the response is still fresh or within the specified staleness limit. However, in the current implementation, this directive is only applied to cache entries that are revalidatable, meaning they have an ETag or Last-Modified header and can be refreshed with a conditional request.

This commit extends the stale-if-error directive to apply to any stale cache entry, whether revalidatable or not. This ensures that clients will continue to receive a cached response even if the original request resulted in an error, and helps to reduce the load on origin servers.
2023-12-13 11:54:38 +01:00
Arturo Bernal b915a3ab33 Improve HttpByteArrayCacheEntrySerializer class by adding new methods and enhancing performance.
This commit adds several new constant values to the HttpByteArrayCacheEntrySerializer class to manage cache entry headers. The HttpByteArrayCacheEntrySerializer class was also updated with a new constructor to set the buffer size and a new method to serialize HTTP cache storage entry objects. Additionally, the code was refactored to enhance performance and remove unnecessary variables.
2023-12-13 11:54:38 +01:00
Arturo Bernal f190e4f52e Avoid using deprecated DateUtils. 2023-12-13 11:54:38 +01:00
Arturo Bernal 4784fdfed4 Fix issue with duplicate parsing of Cache-Control header
Previously, the same Cache-Control header was being parsed twice, once by isExplicitlyNonCacheable and again by calculateFreshnessLifetime. The parsing code was extracted from calculateFreshnessLifetime and enhanced to include the main cache control directive that isExplicitlyNonCacheable could use to make its decision. This improves the efficiency and accuracy of the caching logic.
2023-12-13 11:54:38 +01:00
Arturo Bernal cfcdd11cb6 Allow certain responses from a POST to be cacheable.
Update ResponseCachingPolicy to allow caching of responses to POST requests under certain circumstances, as specified in RFC 2616 and explained in more detail in draft-ietf-httpbis-p2-semantics-20#section-2.3.4. This change extends the cacheability of responses beyond GET and HEAD methods, improving the cache's efficiency and reducing network traffic.
2023-12-13 11:54:38 +01:00
Arturo Bernal 019cf460ec Fix handling of cached responses with variants and different ETag values.
Previously, the getCacheEntry method was not correctly selecting the matching variant for a given request, which led to incorrect behavior when serving cached responses.
This commit improves the method's logic to correctly identify the cache entry using the request's cache key, and then select the variant with the matching ETag value. If no matching variant is found, the cache entry is considered stale and a new response is fetched from the origin server. The fix includes a new test case to ensure the correct behavior of the method in this scenario
2023-12-13 11:54:38 +01:00
Arturo Bernal d1f46e0c66 Fix Heuristic caching for URIs with query strings by adhering to RFC 2616 Section 13.9. The change is based on the fact that caches MUST NOT treat responses to such URIs as fresh unless the server provides an explicit expiration time. However, the updated RFC 7234 note indicates that it would be ok to introduce a configuration option that relaxed this rule. Therefore, a new configuration option is added to allow HTTP/1.1 responses with query strings to be cached. 2023-12-13 11:54:38 +01:00
Oleg Kalnichevski f7de67ff25 Upgraded project version to 5.4-alpha1 2023-12-13 11:54:30 +01:00
Arturo Bernal 7d853d521e Fix Response Body Truncation Issue in ContentResponseHandler (#521)
Resolved a bug where the response body was truncated to 256 bytes in all cases, including successful responses.
2023-12-11 12:19:48 +01:00
Oleg Kalnichevski 9e3d79bede Fixed NPE in debug log 2023-12-10 12:40:50 +01:00
Oleg Kalnichevski 6ad6b82883 Upgraded API compatibility level to 5.3 2023-12-06 21:18:25 +01:00
Arturo Bernal 5ab7f21dcb Refactor ExponentialBackoffManager and TestLinearBackoffManager Tests to Remove Thread.sleep(). (#495)
This commit enhances the ExponentialBackoffManager and TestLinearBackoffManager unit tests by replacing the use of Thread.sleep() with direct manipulation of internal state to simulate the cooldown period. This change improves test reliability and ensures consistent behavior in resource-constrained environments.
2023-12-06 20:36:57 +01:00
Arturo Bernal 5c69779f7d Fix features BackoffManager Unit Tests in Resource-Constrained Environments. (#494)
This commit improves the reliability of BackoffManager unit tests by replacing the use of Thread.sleep() with a more robust approach that manipulates lastRouteProbes to simulate the cooldown period. This enhancement ensures that the tests run successfully even in resource-constrained environments, making them more resilient and reliable.
2023-12-06 20:36:40 +01:00
Oleg Kalnichevski f6a37780cf Upgraded HttpClient version to 5.3.1-SNAPSHOT 2023-12-06 16:54:47 +01:00
Oleg Kalnichevski cf20ea3915 Updated release notes for HttpClient 5.3 release 2023-12-03 09:27:07 +01:00
Oleg Kalnichevski f7ac968aaf HTTPCLIENT-2310: Async Connect exec handler incorrectly pipes CONNECT requests through the main request protocol chain 2023-12-02 11:31:41 +01:00
Oleg Kalnichevski a46c9e5656 Added missing #disconnectEndpoint method to AsyncConnectExec 2023-11-30 13:33:04 +01:00
nfawcett 8a2b0f584a
Improve debug logging around connections that cannot be reused (#515) 2023-11-29 16:50:47 +01:00
Gary Gregory ed1c1d61f2 Use String#isEmpty() 2023-11-28 11:29:24 -05:00
Oleg Kalnichevski efe2598a30 Classic test suits to execute in plain and TLS modes 2023-11-28 11:08:38 +01:00
Oleg Kalnichevski 9ec63474c8 Upgraded HttpCore to version 5.2.4 2023-11-28 09:46:46 +01:00
Cédric Tabin 6d60624cd3 Fixes Invalid Proxy exception when using a SSL client without Proxy 2023-11-23 14:09:34 +01:00
Oleg Kalnichevski 83d603c9d8 SEE OTHER redirect handling fix 2023-11-19 18:47:40 +01:00
dependabot[bot] 3486b47452 Bump com.googlecode.maven-download-plugin:download-maven-plugin
Bumps [com.googlecode.maven-download-plugin:download-maven-plugin](https://github.com/maven-download-plugin/maven-download-plugin) from 1.6.8 to 1.7.1.
- [Release notes](https://github.com/maven-download-plugin/maven-download-plugin/releases)
- [Commits](https://github.com/maven-download-plugin/maven-download-plugin/compare/1.6.8...1.7.1)

---
updated-dependencies:
- dependency-name: com.googlecode.maven-download-plugin:download-maven-plugin
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-19 11:46:28 +01:00
dependabot[bot] 82185a3a02 Bump org.junit:junit-bom from 5.9.3 to 5.10.1
Bumps [org.junit:junit-bom](https://github.com/junit-team/junit5) from 5.9.3 to 5.10.1.
- [Release notes](https://github.com/junit-team/junit5/releases)
- [Commits](https://github.com/junit-team/junit5/compare/r5.9.3...r5.10.1)

---
updated-dependencies:
- dependency-name: org.junit:junit-bom
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-19 11:45:57 +01:00
Carter Kozak 180d90c847
HTTPCLIENT-2305: SSLConnectionSocketFactory allows socket.connect to be decorated (#499) 2023-11-02 10:19:52 -04:00
HappyHacker123 f78c4ffad1 Change scope of slf4j-api to test. 2023-11-02 14:50:42 +01:00
Marcono1234 19f3922b37 HTTPCLIENT-2302: Add comment to TrustStrategy usage in examples (#492) 2023-10-12 15:34:42 +02:00
Marcono1234 9c83250ab4
Add security warning to TrustStrategy implementations documentation (#490) 2023-10-03 22:14:12 +02:00
Oleg Kalnichevski 19ab1111c7 More consistent handling of OperationTimeoutException in MemcachedHttpCacheStorage 2023-09-29 15:24:37 +02:00
Oleg Kalnichevski 6d1aafaf87 HTTPCLIENT-2300: abstract char message consumers to use UTF-8 by default if a charset has not been explicitly specified by the Content-Type 2023-09-26 16:41:24 +02:00
Oleg Kalnichevski 11c7af28c4 HTTPCLIENT-2299: Socket timeout value set via DefaultManagedHttpClientConnection#setSocketTimeout is not correctly persisted and can be overwritten upon connection activation 2023-09-23 10:55:57 +02:00
Oleg Kalnichevski dbe368983c Upgraded HttpCore to version 5.2.3 2023-09-22 15:53:34 +02:00
Oleg Kalnichevski aa5a7c7fe0 HTTPCLIENT-2292: HttpClient ignores socketConfig#getSocksProxyAddress 2023-08-31 16:58:09 +02:00
cachescrubber 509ba6753f
Document exec chain behaviour when automatic retries are enabled. (#480) 2023-08-31 16:55:37 +02:00
Konrad Windszus f00e18d9cc HTTPCLIENT-2295 Fix links to Core Javadoc 2023-08-31 12:49:45 +02:00
Oleg Kalnichevski 8a54e70359 HTTPCLIENT-2291: fixed inconsistency in behavior between the class and async implementation of the request re-execution. The async request retry exec will now re-start request execution from itself instead of form the very beginning of the execution chain 2023-08-31 09:35:17 +02:00
Oleg Kalnichevski 9748d1baf8 Updated project wesite URL 2023-08-20 10:56:20 +02:00
Oleg Kalnichevski 9d23ddbea7 Upgraded HttpClient version to 5.3-alpha2-SNAPSHOT 2023-08-19 18:39:58 +02:00
Oleg Kalnichevski 22a257c2c2 Javadoc fix 2023-08-15 11:21:21 +02:00
Oleg Kalnichevski 09eddd9fa1 Updated release notes for HttpClient 5.3 alpha1 release 2023-08-15 10:50:08 +02:00
Oleg Kalnichevski e4eada63e4 Fixed potential NPE in DigestScheme 2023-08-13 18:08:02 +02:00
Oleg Kalnichevski 091c822edc Removed test case requiring online DNS name resolution 2023-08-12 17:14:53 +02:00
Oleg Kalnichevski 2176eb3861 GGS based experimental authentication schemes deprecated and disabled by default 2023-08-12 17:14:53 +02:00
Oleg Kalnichevski 83c6079e65 NTLM scheme deprecated and disabled by default 2023-08-12 17:14:53 +02:00
Arturo Bernal 8aa4fbc8de Improve AIMDBackoffManager Tests Stability
Enhanced test robustness for AIMDBackoffManager by introducing buffers to sleep durations in cooldown-related tests and adjusting the concurrency test. Due to persistent instability, removed the time-dependent `probeDoesNotAdjustDuringCooldownPeriod` test.
2023-08-12 17:14:53 +02:00
Arturo Bernal f203dcd34e Add AbstractBackoff, LinearBackoffManager, and ExponentialBackoffManager classes
- Create AbstractBackoff class as a base for different backoff strategies
- Add LinearBackoffManager class for implementing linear backoff algorithm in networking and communication systems. This class provides a thread-safe and configurable implementation of linear backoff, allowing for gradual adjustment of maximum connection pool sizes for a given route based on traffic and other factors. The class supports customizable cool-down periods and increment values for each route, and uses a ConcurrentHashMap to ensure thread safety and accurate tracking of backoff and probe attempts
- Implement ExponentialBackoffManager for connection pool control.
This commit introduces the ExponentialBackoffManager class, which manages the connection pool control for HTTP routes based on the Exponential Backoff algorithm. This implementation helps improve connection handling and stability in case of connection failures or network issues.
2023-08-12 17:14:53 +02:00