Package nzilbb.labbcat.http
Class HttpRequestGet
java.lang.Object
nzilbb.labbcat.http.HttpRequestGet
GET HTTP request, using ordinary default request encoding, and encoding all arguments
in the URL string
- Author:
- Robert Fromont robert@fromont.net.nz
-
Constructor Summary
ConstructorsConstructorDescriptionHttpRequestGet
(String baseUrl) Constructor.HttpRequestGet
(String baseUrl, String authorization) Constructor.HttpRequestGet
(URL baseUrl) Constructor.HttpRequestGet
(URL baseUrl, String authorization) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionget()
Fetches the request responseGetter forsAuthorization
: The HTTP authorization string, or null if not required.Getter forurlBaseUrl
: Base URL for the requestFetches the request responseGetter formHeaders
: HTTP request headers.Getter formethod
: HTTP method.Getter formParameters
: Resuest parametersGenerates the query string.setAuthorization
(String sNewAuthorization) Setter forsAuthorization
: The HTTP authorization string, or null if not required.setBaseUrl
(URL urlNewBaseUrl) Setter forurlBaseUrl
: Base URL for the requestSets a request parameter valuesetHeaders
(HashMap<String, String> mNewHeaders) Setter formHeaders
: HTTP request headers.setLanguage
(String language) Set the Accept-Language header with the given language code, if any.,Setter formethod
: HTTP method.setParameter
(String sParameter, Object oValue) Sets a request parameter valuesetParameters
(HashMap<String, Object> mNewParameters) Setter formParameters
: Resuest parametersSets the user-agent header to indicate the name/version of the library.toString()
String representation of the request, for logging.
-
Constructor Details
-
HttpRequestGet
Constructor.- Parameters:
baseUrl
- URL for LaBB-CAT server.
-
HttpRequestGet
Constructor.- Parameters:
baseUrl
- Base URL of the LaBB-CAT server.- Throws:
MalformedURLException
- If the URL is invalid.
-
HttpRequestGet
Constructor.- Parameters:
baseUrl
- Base URL of the LaBB-CAT server.authorization
- Authorization string if any - e.g. value for "Authorization" header.
-
HttpRequestGet
Constructor.- Parameters:
baseUrl
- Base URL of the LaBB-CAT server.authorization
- Authorization string if any - e.g. value for "Authorization" header.- Throws:
MalformedURLException
- If the URL is invalid.
-
-
Method Details
-
getBaseUrl
Getter forurlBaseUrl
: Base URL for the request- Returns:
- Base URL for the request
-
setBaseUrl
Setter forurlBaseUrl
: Base URL for the request- Parameters:
urlNewBaseUrl
- Base URL for the request- Returns:
- A reference to this object, so that setters can be chained.
-
getParameters
Getter formParameters
: Resuest parameters- Returns:
- Resuest parameters
-
setParameters
Setter formParameters
: Resuest parameters- Parameters:
mNewParameters
- Resuest parameters- Returns:
- A reference to this object, so that setters can be chained.
-
getHeaders
Getter formHeaders
: HTTP request headers.- Returns:
- HTTP request headers.
-
setHeaders
Setter formHeaders
: HTTP request headers.- Parameters:
mNewHeaders
- HTTP request headers.- Returns:
- A reference to this object, so that setters can be chained.
-
getAuthorization
Getter forsAuthorization
: The HTTP authorization string, or null if not required.- Returns:
- The HTTP authorization string, or null if not required.
-
setAuthorization
Setter forsAuthorization
: The HTTP authorization string, or null if not required.- Parameters:
sNewAuthorization
- The HTTP authorization string, or null if not required.- Returns:
- A reference to this object, so that setters can be chained.
-
getMethod
Getter formethod
: HTTP method.- Returns:
- HTTP method.
-
setMethod
Setter formethod
: HTTP method.- Parameters:
newMethod
- HTTP method.- Returns:
- A reference to this object, so that setters can be chained.
-
setUserAgent
Sets the user-agent header to indicate the name/version of the library.- Returns:
- A reference to this object, so that setters can be chained.
-
setLanguage
Set the Accept-Language header with the given language code, if any.,- Parameters:
language
- The language code, e.g. "es-AR", or null.- Returns:
- A reference to this object.
-
setParameter
Sets a request parameter value- Parameters:
sParameter
- Parameter name.oValue
- Paremeter value.- Returns:
- A reference to this object, so that setters can be chained.
-
setHeader
Sets a request parameter value- Parameters:
sKey
- Header name.sValue
- header value.- Returns:
- A reference to this object, so that setters can be chained.
-
getConnection
Fetches the request response- Returns:
- Connection for the response
- Throws:
IOException
- If an IO error occurs.MalformedURLException
- If the URL is invalid.
-
getQueryString
Generates the query string.- Returns:
- The query string.
- Throws:
UnsupportedEncodingException
- If an encoding error occurs.
-
get
Fetches the request response- Returns:
- Input stream of the response
- Throws:
IOException
- If an IO error occurs.MalformedURLException
- If the URL is invalid.
-
toString
String representation of the request, for logging.
-