Skip to content

Commit 3c06a12

Browse files
authored
Mark HTTPClient as deprecated (#2020)
* Mark HTTPClient as deprecated Signed-off-by: Julien Nioche <julien@digitalpebble.com> * Formatting! Signed-off-by: Julien Nioche <julien@digitalpebble.com> --------- Signed-off-by: Julien Nioche <julien@digitalpebble.com>
1 parent 54c4a6d commit 3c06a12

8 files changed

Lines changed: 30 additions & 18 deletions

File tree

core/src/main/java/org/apache/stormcrawler/protocol/DelegatorProtocol.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
*
3939
* <pre>
4040
* protocol.delegator.config:
41-
* - className: "org.apache.stormcrawler.protocol.httpclient.HttpProtocol"
41+
* - className: "org.apache.stormcrawler.protocol.okhttp.HttpProtocol"
4242
* filters:
4343
* domain: "example.com"
4444
* depth: "3"
@@ -50,7 +50,7 @@
5050
* regex:
5151
* - \.pdf
5252
* - \.doc
53-
* - className: "org.apache.stormcrawler.protocol.selenium.SeleniumProtocol"
53+
* - className: "org.apache.stormcrawler.protocol.playwright.HttpProtocol"
5454
* </pre>
5555
*
5656
* Typically, the last one in the list must not have filters as it is used as a default value. The

core/src/main/java/org/apache/stormcrawler/protocol/ProtocolFactory.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,9 @@ private void configure(Config conf) {
7171
if (StringUtils.isBlank(protocolimplementation)) {
7272
// set the default values
7373
if (protocol.equalsIgnoreCase("http")) {
74-
protocolimplementation =
75-
"org.apache.stormcrawler.protocol.httpclient.HttpProtocol";
74+
protocolimplementation = "org.apache.stormcrawler.protocol.okhttp.HttpProtocol";
7675
} else if (protocol.equalsIgnoreCase("https")) {
77-
protocolimplementation =
78-
"org.apache.stormcrawler.protocol.httpclient.HttpProtocol";
76+
protocolimplementation = "org.apache.stormcrawler.protocol.okhttp.HttpProtocol";
7977
} else {
8078
throw new RuntimeException(paramName + "should not have an empty value");
8179
}

core/src/main/java/org/apache/stormcrawler/protocol/httpclient/HttpProtocol.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,14 @@
6868
import org.apache.stormcrawler.util.CookieConverter;
6969
import org.slf4j.LoggerFactory;
7070

71-
/** Uses Apache httpclient to handle http and https. */
71+
/**
72+
* Uses Apache httpclient to handle http and https.
73+
*
74+
* @deprecated The Apache HttpClient protocol implementation is deprecated and will be removed in
75+
* the next major release of StormCrawler. Use the OkHttp implementation ({@link
76+
* org.apache.stormcrawler.protocol.okhttp.HttpProtocol}) instead.
77+
*/
78+
@Deprecated
7279
public class HttpProtocol extends AbstractHttpProtocol
7380
implements ResponseHandler<ProtocolResponse> {
7481

core/src/main/java/org/apache/stormcrawler/proxy/MultiProxyManager.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import org.apache.commons.lang3.ArrayUtils;
3131
import org.apache.storm.Config;
3232
import org.apache.stormcrawler.Metadata;
33-
import org.apache.stormcrawler.protocol.httpclient.HttpProtocol;
3433
import org.apache.stormcrawler.util.ConfUtils;
3534
import org.slf4j.LoggerFactory;
3635

@@ -48,7 +47,7 @@ public enum ProxyRotation {
4847
private final AtomicInteger lastAccessedIndex = new AtomicInteger(0);
4948
private Map<SCProxy, SCProxy> proxyLookupMap;
5049

51-
private static final org.slf4j.Logger LOG = LoggerFactory.getLogger(HttpProtocol.class);
50+
private static final org.slf4j.Logger LOG = LoggerFactory.getLogger(MultiProxyManager.class);
5251

5352
/** Default constructor for setting up the proxy manager. */
5453
private void init(ProxyRotation rotation) {

core/src/main/resources/crawler-default.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,11 @@ config:
194194
robots.error.cache.spec: "maximumSize=10000,expireAfterWrite=1h"
195195

196196
protocols: "http,https,file"
197-
http.protocol.implementation: "org.apache.stormcrawler.protocol.httpclient.HttpProtocol"
198-
https.protocol.implementation: "org.apache.stormcrawler.protocol.httpclient.HttpProtocol"
197+
# NOTE: the Apache HttpClient protocol implementation
198+
# (org.apache.stormcrawler.protocol.httpclient.HttpProtocol) is deprecated and will be removed in
199+
# the next major release of StormCrawler. OkHttp is now the default.
200+
http.protocol.implementation: "org.apache.stormcrawler.protocol.okhttp.HttpProtocol"
201+
https.protocol.implementation: "org.apache.stormcrawler.protocol.okhttp.HttpProtocol"
199202
file.protocol.implementation: "org.apache.stormcrawler.protocol.file.FileProtocol"
200203

201204
# number of instances for each protocol implementation

core/src/test/java/org/apache/stormcrawler/protocol/httpclient/HttpClientProtocolProxyManagerTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.apache.stormcrawler.proxy.SingleProxyManager;
2727
import org.junit.jupiter.api.Test;
2828

29+
@SuppressWarnings("deprecation")
2930
class HttpClientProtocolProxyManagerTest {
3031

3132
@Test

docs/src/main/asciidoc/configuration.adoc

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,10 @@ is defined.
201201
| http.basicauth.password | - | Password for http.basicauth.user.
202202
| http.basicauth.user | - | Username for Basic Authentication.
203203
| http.content.limit | -1 | Maximum HTTP response body size (bytes). Default: no limit.
204-
| http.protocol.implementation | org.apache.stormcrawler.protocol.httpclient.HttpProtocol | HTTP Protocol
205-
implementation.
204+
| http.protocol.implementation | org.apache.stormcrawler.protocol.okhttp.HttpProtocol | HTTP Protocol
205+
implementation. Note: the Apache HttpClient implementation
206+
(`org.apache.stormcrawler.protocol.httpclient.HttpProtocol`) is *deprecated* and will be removed in
207+
the next major release.
206208
| http.proxy | - | Full **SCProxy** connection string read by SingleProxyManager when that manager is selected, e.g. `http://user:pass@proxy.example.com:8080`.
207209
| http.proxy.file | - | Proxy connection-string file read by MultiProxyManager when that manager is selected.
208210
| http.proxy.host | - | SingleProxyManager component proxy host.
@@ -225,8 +227,10 @@ implementation.
225227
| http.store.headers | false | Whether to store response headers.
226228
| http.timeout | 10000 | Connection timeout (ms).
227229
| http.use.cookies | false | Use cookies in subsequent requests.
228-
| https.protocol.implementation | org.apache.stormcrawler.protocol.httpclient.HttpProtocol | HTTPS Protocol
229-
implementation.
230+
| https.protocol.implementation | org.apache.stormcrawler.protocol.okhttp.HttpProtocol | HTTPS Protocol
231+
implementation. Note: the Apache HttpClient implementation
232+
(`org.apache.stormcrawler.protocol.httpclient.HttpProtocol`) is *deprecated* and will be removed in
233+
the next major release.
230234
| partition.url.mode | byHost | Defines how URLs are partitioned: byHost, byDomain, or byIP.
231235
| protocols | http,https,file | Supported protocols.
232236
| redirections.allowed | true | If true, emit redirect target URLs as "outlinks" to the status stream. If false, do not follow redirects. See also `http.allow.redirects`.

docs/src/main/asciidoc/internals.adoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -395,13 +395,13 @@ The following network protocols are implemented in StormCrawler:
395395
* link:https://github.com/apache/stormcrawler/blob/main/core/src/main/java/org/apache/stormcrawler/protocol/file/FileProtocol.java[FileProtocol]
396396

397397
===== DelegatorProtocol
398-
The link:https://github.com/apache/stormcrawler/blob/main/core/src/main/java/org/apache/stormcrawler/protocol/DelegatorProtocol.java[DelegatorProtocol] enables selection from a collection of sub-protocols using filters based on metadata and URL patterns. The last protocol in the list acts as the default. This is useful when certain URLs need to be fetched with a browser-based protocol (e.g., Selenium) while the majority use a standard HTTP client.
398+
The link:https://github.com/apache/stormcrawler/blob/main/core/src/main/java/org/apache/stormcrawler/protocol/DelegatorProtocol.java[DelegatorProtocol] enables selection from a collection of sub-protocols using filters based on metadata and URL patterns. The last protocol in the list acts as the default. This is useful when certain URLs need to be fetched with a browser-based protocol (e.g., Playwright) while the majority use a standard HTTP client.
399399

400400
[source,yaml]
401401
----
402402
http.protocol.implementation: "org.apache.stormcrawler.protocol.DelegatorProtocol"
403403
protocol.delegator.config:
404-
- className: "org.apache.stormcrawler.protocol.httpclient.HttpProtocol"
404+
- className: "org.apache.stormcrawler.protocol.playwright.HttpProtocol"
405405
filters:
406406
domain: "example.com"
407407
- className: "org.apache.stormcrawler.protocol.okhttp.HttpProtocol"
@@ -421,7 +421,7 @@ http.protocol.implementation: "org.apache.stormcrawler.protocol.okhttp.HttpProto
421421
https.protocol.implementation: "org.apache.stormcrawler.protocol.okhttp.HttpProtocol"
422422
----
423423

424-
* link:https://github.com/apache/stormcrawler/blob/main/core/src/main/java/org/apache/stormcrawler/protocol/httpclient/HttpProtocol.java[HttpClient]
424+
* link:https://github.com/apache/stormcrawler/blob/main/core/src/main/java/org/apache/stormcrawler/protocol/httpclient/HttpProtocol.java[HttpClient] (*deprecated* — will be removed in the next major release; use OKHttp instead)
425425
* link:https://github.com/apache/stormcrawler/blob/main/external/selenium/src/main/java/org/apache/stormcrawler/protocol/selenium/SeleniumProtocol.java[Selenium]
426426
* link:https://github.com/apache/stormcrawler/blob/main/core/src/main/java/org/apache/stormcrawler/protocol/okhttp/HttpProtocol.java[OKHttp]
427427

0 commit comments

Comments
 (0)