public class AsyncScrapingHttpClient2 extends AbstractScrapingHttpClient
Modifier and Type | Class and Description |
---|---|
static class |
AsyncScrapingHttpClient2.SharedAsyncHttpClient
Class to wrap an async client so it can be shared (save on resources) but still closed like normal
|
GLOBAL_REQUESTS_THREAD_LOCK, session
REDIRECT_WITH_POST_ENTITY_STATUS_CODE
Constructor and Description |
---|
AsyncScrapingHttpClient2(ScrapingSession session)
Creates the client
|
AsyncScrapingHttpClient2(ScrapingSession session,
boolean allowSharingUnderlyingClient)
Creates the client
|
AsyncScrapingHttpClient2(ScrapingSession session,
boolean followRedirects,
boolean autoSetCookies,
org.asynchttpclient.AsyncHttpClient client,
boolean showActualRequestHeaders)
Forcibly sets the underlying client.
|
AsyncScrapingHttpClient2(ScrapingSession session,
boolean followRedirects,
boolean autoSetCookies,
boolean allowSharingUnderlyingClient,
java.util.Set<java.lang.String> acceptOnlyCiphers,
java.lang.String... acceptOnlyProtocols)
Creates the client
|
AsyncScrapingHttpClient2(ScrapingSession session,
boolean followRedirects,
boolean autoSetCookies,
java.util.Set<java.lang.String> acceptOnlyCiphers,
java.lang.String... acceptOnlyProtocols)
Creates the client
|
Modifier and Type | Method and Description |
---|---|
void |
clearCookies()
Clears all cookies from this client
|
void |
close() |
java.util.List<ScrapingCookie> |
getCookies()
Returns a list of all the cookies for the current client, for any domain
|
static java.util.Map<HttpClientKey,SharedHttpClient> |
getCurrentOpenClients()
Returns a map of the currently open clients (for debugging purposes)
|
protected ScrapingResponse |
issueRequestInternal(ScrapingRequest request)
Issues the given request
|
void |
setCookie(ScrapingCookie cookie)
Sets the cookie
|
java.lang.String |
toString() |
void |
updateSessionClientInfo()
Tells the client the session http info value has changed.
|
boolean |
usesHint(ScrapingHint hint)
Returns whether or not this client implementation uses the given hint.
|
convertScrapeableFileToRequest, getProxy, isRedirectStatusCode, issueRequest, logDebug, logDebug, logError, logError, logInfo, logInfo, logWarn, logWarn, scrapeFile, setProxyServer
public AsyncScrapingHttpClient2(@Nullable ScrapingSession session)
session
- The session for logging (and converting scrapeable files)public AsyncScrapingHttpClient2(@Nullable ScrapingSession session, boolean allowSharingUnderlyingClient)
session
- The session for logging (and converting scrapeable files)allowSharingUnderlyingClient
- True if this can share a client with other scrapes (not cookies though), false to require this scrape to have a unique client reference and connection poolpublic AsyncScrapingHttpClient2(@Nullable ScrapingSession session, boolean followRedirects, boolean autoSetCookies, @NotNull org.asynchttpclient.AsyncHttpClient client, boolean showActualRequestHeaders)
session
- The session for logging and converting scrapeable filesfollowRedirects
- Whether or not to follow redirects automatically. Set to false if using for proxyingautoSetCookies
- True if cookies should be tracked automatically, false otherwiseclient
- The client to use. Please note that if you want all cookies to be properly set you should not have this client configured to followshowActualRequestHeaders
- True if we should show the actual headers sent, false to try and guess. Generally this should be set to true, but some providers
don't allow it, so it can be set here if the manual configuration won't allow it redirects, but should instead tell it not to but then pass in true for the
followRedirects flagpublic AsyncScrapingHttpClient2(@Nullable ScrapingSession session, boolean followRedirects, boolean autoSetCookies, @NotNull java.util.Set<java.lang.String> acceptOnlyCiphers, java.lang.String... acceptOnlyProtocols)
session
- The session for logging and converting scrapeable filesfollowRedirects
- Whether or not to follow redirects automatically. Set to false if using for proxyingautoSetCookies
- True if cookies should be tracked automatically, false otherwiseacceptOnlyCiphers
- A set of ciphers to accept (or empty set to use defaults)acceptOnlyProtocols
- An array of protocols to accept. Note that empty means use the default (and on that failing to try all protocols)public AsyncScrapingHttpClient2(@Nullable ScrapingSession session, boolean followRedirects, boolean autoSetCookies, boolean allowSharingUnderlyingClient, @NotNull java.util.Set<java.lang.String> acceptOnlyCiphers, java.lang.String... acceptOnlyProtocols)
session
- The session for logging and converting scrapeable filesfollowRedirects
- Whether or not to follow redirects automatically. Set to false if using for proxyingautoSetCookies
- True if cookies should be tracked automatically, false otherwiseallowSharingUnderlyingClient
- True if this can share a client with other scrapes (not cookies though), false to require this scrape to have a unique client reference and connection poolacceptOnlyCiphers
- A set of ciphers to accept (or empty set to use defaults)acceptOnlyProtocols
- An array of protocols to accept. Note that empty means use the default (and on that failing to try all protocols)public static java.util.Map<HttpClientKey,SharedHttpClient> getCurrentOpenClients()
public void updateSessionClientInfo()
ScrapingHttpClient
public void setCookie(@NotNull ScrapingCookie cookie)
cookie
- The cookie to set@NotNull protected ScrapingResponse issueRequestInternal(@NotNull ScrapingRequest request)
issueRequestInternal
in class AbstractScrapingHttpClient
request
- The request to be issuedpublic boolean usesHint(@NotNull ScrapingHint hint)
hint
- The hint to test@NotNull public java.util.List<ScrapingCookie> getCookies()
public void clearCookies()
public void close()
public java.lang.String toString()
toString
in class java.lang.Object