public class HttpUtil
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private static java.text.SimpleDateFormat |
HTTP_DATE_FORMAT |
private static nl.basjes.parse.useragent.UserAgentAnalyzer |
userAgentAnalyzer |
Constructor and Description |
---|
HttpUtil() |
Modifier and Type | Method and Description |
---|---|
static nl.basjes.parse.useragent.UserAgent |
analyzeUserAgent(java.lang.String userAgent)
Parse the User-Agent string from a HTTP request and return
information about what it actually means.
|
static long |
getContentLength(org.apache.http.HttpResponse response)
Get the content length from the headers in the response.
|
static java.lang.String |
getContentType(org.apache.http.HttpResponse response)
Get the content type of the content from the headers
in the response.
|
static java.util.Date |
getDate(org.apache.http.HttpResponse response,
java.lang.String header,
java.util.Date defaultValue) |
static java.util.Date |
getLastModified(org.apache.http.HttpResponse response)
Get the date the content was last modified from the headers
in the response.
|
static java.lang.Long |
getLong(org.apache.http.HttpResponse response,
java.lang.String header,
java.lang.Long defaultValue) |
static java.lang.String |
getString(org.apache.http.HttpResponse response,
java.lang.String header,
java.lang.String defaultValue) |
static java.lang.String |
getSummaryOfUserAgent(java.lang.String userAgent)
Get a summary of the user agent:
Browser with major version
Operating system with version
Typy of device (eg. desktop, phone, etc.)
|
static void |
shutdown(org.apache.http.impl.client.CloseableHttpClient client)
Safely shuts down a http client and it's connection manager
without trowing an exception.
|
private static final java.text.SimpleDateFormat HTTP_DATE_FORMAT
private static nl.basjes.parse.useragent.UserAgentAnalyzer userAgentAnalyzer
public static long getContentLength(org.apache.http.HttpResponse response)
response
- The response from a HTTP requestpublic static java.util.Date getLastModified(org.apache.http.HttpResponse response)
response
- The response from a HTTP requestpublic static java.lang.String getContentType(org.apache.http.HttpResponse response)
response
- The response from a HTTP requestpublic static java.lang.String getString(org.apache.http.HttpResponse response, java.lang.String header, java.lang.String defaultValue)
public static java.lang.Long getLong(org.apache.http.HttpResponse response, java.lang.String header, java.lang.Long defaultValue)
public static java.util.Date getDate(org.apache.http.HttpResponse response, java.lang.String header, java.util.Date defaultValue)
public static void shutdown(org.apache.http.impl.client.CloseableHttpClient client)
public static nl.basjes.parse.useragent.UserAgent analyzeUserAgent(java.lang.String userAgent)
public static java.lang.String getSummaryOfUserAgent(java.lang.String userAgent)