public class HttpUtils
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
HttpUtils.HTTPResponseResult
Utility class wraps the http requests result and some utility methods
for retrieving info and content for the result.
|
static interface |
HttpUtils.RedirectHandler
The redirect handler will cancel/proceed the redirection.
|
Constructor and Description |
---|
HttpUtils() |
Modifier and Type | Method and Description |
---|---|
static org.apache.http.impl.client.DefaultHttpClient |
getHttpClient(java.lang.String usernamePropertyName,
java.lang.String passwordPropertyName,
java.lang.String address,
org.apache.http.client.CredentialsProvider credentialsProvider)
Returns the preconfigured http client,
using CertificateVerificationService, timeouts, user-agent,
hostname verifier, proxy settings are used from global java settings,
if protected site is hit asks for credentials
using util.swing.AuthenticationWindow.
|
static HttpUtils.HTTPResponseResult |
openURLConnection(java.lang.String address)
Opens a connection to the address.
|
static HttpUtils.HTTPResponseResult |
openURLConnection(java.lang.String address,
java.lang.String[] headerParamNames,
java.lang.String[] headerParamValues)
Opens a connection to the address.
|
static HttpUtils.HTTPResponseResult |
openURLConnection(java.lang.String address,
java.lang.String usernamePropertyName,
java.lang.String passwordPropertyName,
java.lang.String[] headerParamNames,
java.lang.String[] headerParamValues)
Opens a connection to the address.
|
static HttpUtils.HTTPResponseResult |
postFile(java.lang.String address,
java.lang.String fileParamName,
java.io.File file)
Posts a file to the address.
|
static HttpUtils.HTTPResponseResult |
postFile(java.lang.String address,
java.lang.String fileParamName,
java.io.File file,
java.lang.String usernamePropertyName,
java.lang.String passwordPropertyName)
Posts a file to the address.
|
static HttpUtils.HTTPResponseResult |
postForm(java.lang.String address,
java.util.List<java.lang.String> headerParamNames,
java.util.List<java.lang.String> headerParamValues)
Posting form to address.
|
static HttpUtils.HTTPResponseResult |
postForm(java.lang.String address,
java.lang.String usernamePropertyName,
java.lang.String passwordPropertyName,
java.util.ArrayList<java.lang.String> formParamNames,
java.util.ArrayList<java.lang.String> formParamValues,
int usernameParamIx,
int passwordParamIx)
Posting form to address.
|
static HttpUtils.HTTPResponseResult |
postForm(java.lang.String address,
java.lang.String usernamePropertyName,
java.lang.String passwordPropertyName,
java.util.ArrayList<java.lang.String> formParamNames,
java.util.ArrayList<java.lang.String> formParamValues,
int usernameParamIx,
int passwordParamIx,
HttpUtils.RedirectHandler redirectHandler)
Posting form to address.
|
static HttpUtils.HTTPResponseResult |
postForm(java.lang.String address,
java.lang.String usernamePropertyName,
java.lang.String passwordPropertyName,
java.util.ArrayList<java.lang.String> formParamNames,
java.util.ArrayList<java.lang.String> formParamValues,
int usernameParamIx,
int passwordParamIx,
HttpUtils.RedirectHandler redirectHandler,
java.util.List<java.lang.String> headerParamNames,
java.util.List<java.lang.String> headerParamValues)
Posting form to address.
|
public static HttpUtils.HTTPResponseResult openURLConnection(java.lang.String address)
address
- the address to contact.public static HttpUtils.HTTPResponseResult openURLConnection(java.lang.String address, java.lang.String[] headerParamNames, java.lang.String[] headerParamValues)
address
- the address to contact.headerParamNames
- additional header name to includeheaderParamValues
- corresponding header value to includepublic static HttpUtils.HTTPResponseResult openURLConnection(java.lang.String address, java.lang.String usernamePropertyName, java.lang.String passwordPropertyName, java.lang.String[] headerParamNames, java.lang.String[] headerParamValues)
address
- the address to contact.usernamePropertyName
- the property to use to retrieve/store
username value if protected site is hit, for username
ConfigurationService service is used.passwordPropertyName
- the property to use to retrieve/store
password value if protected site is hit, for password
CredentialsStorageService service is used.headerParamNames
- additional header name to includeheaderParamValues
- corresponding header value to includepublic static HttpUtils.HTTPResponseResult postFile(java.lang.String address, java.lang.String fileParamName, java.io.File file)
address
- the address to post the form to.fileParamName
- the name of the param for the file.file
- the file we will send.public static HttpUtils.HTTPResponseResult postFile(java.lang.String address, java.lang.String fileParamName, java.io.File file, java.lang.String usernamePropertyName, java.lang.String passwordPropertyName)
address
- the address to post the form to.fileParamName
- the name of the param for the file.file
- the file we will send.usernamePropertyName
- the property to use to retrieve/store
username value if protected site is hit, for username
ConfigurationService service is used.passwordPropertyName
- the property to use to retrieve/store
password value if protected site is hit, for password
CredentialsStorageService service is used.public static HttpUtils.HTTPResponseResult postForm(java.lang.String address, java.lang.String usernamePropertyName, java.lang.String passwordPropertyName, java.util.ArrayList<java.lang.String> formParamNames, java.util.ArrayList<java.lang.String> formParamValues, int usernameParamIx, int passwordParamIx) throws java.lang.Throwable
address
- HTTP address.usernamePropertyName
- the property to use to retrieve/store
username value if protected site is hit, for username
ConfigurationService service is used.passwordPropertyName
- the property to use to retrieve/store
password value if protected site is hit, for password
CredentialsStorageService service is used.formParamNames
- the parameter names to include in post.formParamValues
- the corresponding parameter values to use.usernameParamIx
- the index of the username parameter in the
formParamNames and formParamValues
if any, otherwise -1.passwordParamIx
- the index of the password parameter in the
formParamNames and formParamValues
if any, otherwise -1.java.lang.Throwable
public static HttpUtils.HTTPResponseResult postForm(java.lang.String address, java.lang.String usernamePropertyName, java.lang.String passwordPropertyName, java.util.ArrayList<java.lang.String> formParamNames, java.util.ArrayList<java.lang.String> formParamValues, int usernameParamIx, int passwordParamIx, HttpUtils.RedirectHandler redirectHandler) throws java.lang.Throwable
address
- HTTP address.usernamePropertyName
- the property to use to retrieve/store
username value if protected site is hit, for username
ConfigurationService service is used.passwordPropertyName
- the property to use to retrieve/store
password value if protected site is hit, for password
CredentialsStorageService service is used.formParamNames
- the parameter names to include in post.formParamValues
- the corresponding parameter values to use.usernameParamIx
- the index of the username parameter in the
formParamNames and formParamValues
if any, otherwise -1.passwordParamIx
- the index of the password parameter in the
formParamNames and formParamValues
if any, otherwise -1.redirectHandler
- handles redirection, should we redirect and
the actual redirect.java.lang.Throwable
public static HttpUtils.HTTPResponseResult postForm(java.lang.String address, java.util.List<java.lang.String> headerParamNames, java.util.List<java.lang.String> headerParamValues) throws java.lang.Throwable
address
- HTTP address.headerParamNames
- additional header name to includeheaderParamValues
- corresponding header value to includejava.lang.Throwable
public static HttpUtils.HTTPResponseResult postForm(java.lang.String address, java.lang.String usernamePropertyName, java.lang.String passwordPropertyName, java.util.ArrayList<java.lang.String> formParamNames, java.util.ArrayList<java.lang.String> formParamValues, int usernameParamIx, int passwordParamIx, HttpUtils.RedirectHandler redirectHandler, java.util.List<java.lang.String> headerParamNames, java.util.List<java.lang.String> headerParamValues) throws java.lang.Throwable
address
- HTTP address.usernamePropertyName
- the property to use to retrieve/store
username value if protected site is hit, for username
ConfigurationService service is used.passwordPropertyName
- the property to use to retrieve/store
password value if protected site is hit, for password
CredentialsStorageService service is used.formParamNames
- the parameter names to include in post.formParamValues
- the corresponding parameter values to use.usernameParamIx
- the index of the username parameter in the
formParamNames and formParamValues
if any, otherwise -1.passwordParamIx
- the index of the password parameter in the
formParamNames and formParamValues
if any, otherwise -1.redirectHandler
- handles redirection, should we redirect and
the actual redirect.headerParamNames
- additional header name to includeheaderParamValues
- corresponding header value to includejava.lang.Throwable
public static org.apache.http.impl.client.DefaultHttpClient getHttpClient(java.lang.String usernamePropertyName, java.lang.String passwordPropertyName, java.lang.String address, org.apache.http.client.CredentialsProvider credentialsProvider) throws java.io.IOException
usernamePropertyName
- the property to use to retrieve/store
username value if protected site is hit, for username
ConfigurationService service is used.passwordPropertyName
- the property to use to retrieve/store
password value if protected site is hit, for password
CredentialsStorageService service is used.credentialsProvider
- if not null provider will bre reused
in the new clientaddress
- the address we will be connecting tojava.io.IOException
Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under Apache license.