Package net.sf.basedb.util
Class HttpUtil
java.lang.Object
net.sf.basedb.util.HttpUtil
Useful methods related to HTTP stuff in general and
Apache HTTP components in particular.
- Since:
- 2.16
- Author:
- Nicklas
- Last modified
- $Date$
-
Field Summary
Modifier and TypeFieldDescriptionprivate static final org.apache.commons.lang3.time.FastDateFormat
private static nl.basjes.parse.useragent.UserAgentAnalyzer
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic nl.basjes.parse.useragent.UserAgent
analyzeUserAgent
(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 String
getContentType
(org.apache.http.HttpResponse response) Get the content type of the content from the headers in the response.static Date
static Date
getLastModified
(org.apache.http.HttpResponse response) Get the date the content was last modified from the headers in the response.static Long
static String
static String
getSummaryOfUserAgent
(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.
-
Field Details
-
HTTP_DATE_FORMAT
private static final org.apache.commons.lang3.time.FastDateFormat HTTP_DATE_FORMAT -
userAgentAnalyzer
private static nl.basjes.parse.useragent.UserAgentAnalyzer userAgentAnalyzer
-
-
Constructor Details
-
HttpUtil
public HttpUtil()
-
-
Method Details
-
getContentLength
public static long getContentLength(org.apache.http.HttpResponse response) Get the content length from the headers in the response.- Parameters:
response
- The response from a HTTP request- Returns:
- The value of the "Content-Length" header or -1 if not present if it is unparsable
-
getLastModified
Get the date the content was last modified from the headers in the response.- Parameters:
response
- The response from a HTTP request- Returns:
- The value of the "Last-Modified" header or null if not present if it is unparsable
-
getContentType
Get the content type of the content from the headers in the response.- Parameters:
response
- The response from a HTTP request- Returns:
- The value of the "Content-Type" header or null if not present if it is unparsable
-
getString
-
getLong
-
getDate
-
shutdown
public 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. Useful to use in try-catch-finally clauses. -
analyzeUserAgent
Parse the User-Agent string from a HTTP request and return information about what it actually means.- Since:
- 3.12
- See Also:
-
getSummaryOfUserAgent
Get a summary of the user agent: Browser with major version Operating system with version Typy of device (eg. desktop, phone, etc.)- Since:
- 3.12
-