Class AdaptiveHttpRequest
java.lang.Object
ee.jakarta.tck.ws.rs.common.webclient.http.HttpRequest
ee.jakarta.tck.ws.rs.jaxrs21.ee.patch.server.AdaptiveHttpRequest
Represents an HTTP client Request
-
Field Summary
Fields inherited from class ee.jakarta.tck.ws.rs.common.webclient.http.HttpRequest
BASIC_AUTHENTICATION, client, DEFAULT_HTTP_PORT, DEFAULT_SSL_PORT, DIGEST_AUTHENTICATION, NO_AUTHENTICATION -
Constructor Summary
ConstructorsConstructorDescriptionAdaptiveHttpRequest(String requestLine, String host, int port) Creates new HttpRequest based of the passed request line. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddRequestHeader(String header) voidaddRequestHeader(String headerName, String headerValue) addRequestHeaderadds a request header to this request.execute()executewill dispatch the current request to the target server.booleangetFollowRedirectsindicates whether HTTP redirects are followed.getRequestMethodreturns the request type, i.e., GET, POST, etc.getRequestPathreturns the request path for this particular request.org.apache.commons.httpclient.HttpStategetState()Returns the current state for this request.booleanisSecureConnection()indicates if the Request is secure or not.voidsetAuthenticationCredentials(String username, String password, int authType, String realm) setAuthenticationCredentials configures the request to perform authentication.voidsetContent(String content) setContentwill set the body for this request.voidsetFollowRedirects(boolean followRedirects) setFollowRedirectsindicates whether HTTP redirects are followed.voidsetRequestHeader(String headerName, String headerValue) setRequestHeadersets a request header for this request overwritting any previously existing header/values with the same name.voidsetSecureRequest(boolean secure) setSecureRequestconfigures this request to use SSL.voidsetState(org.apache.commons.httpclient.HttpState state) setStatewill set the HTTP state for the current request (i.e.toString()
-
Constructor Details
-
AdaptiveHttpRequest
Creates new HttpRequest based of the passed request line. The request line provied must be in the form of:
METHOD PATH HTTP-VERSION Ex. GET /index.html HTTP/1.0
-
-
Method Details
-
getRequestPath
getRequestPathreturns the request path for this particular request.- Overrides:
getRequestPathin classHttpRequest- Returns:
- String request path
-
getRequestMethod
getRequestMethodreturns the request type, i.e., GET, POST, etc.- Overrides:
getRequestMethodin classHttpRequest- Returns:
- String request type
-
isSecureRequest
public boolean isSecureRequest()isSecureConnection()indicates if the Request is secure or not.- Overrides:
isSecureRequestin classHttpRequest- Returns:
- boolean whether Request is using SSL or not.
-
setSecureRequest
public void setSecureRequest(boolean secure) setSecureRequestconfigures this request to use SSL.- Overrides:
setSecureRequestin classHttpRequest- Parameters:
secure- - whether the Request uses SSL or not.
-
setContent
setContentwill set the body for this request. Note, this is only valid for POST and PUT operations, however, if called and the request represents some other HTTP method, it will be no-op'd.- Overrides:
setContentin classHttpRequest- Parameters:
content- request content
-
setAuthenticationCredentials
public void setAuthenticationCredentials(String username, String password, int authType, String realm) setAuthenticationCredentials configures the request to perform authentication.usernameandpasswordcannot be null.It is legal for
realmto be null.- Overrides:
setAuthenticationCredentialsin classHttpRequest- Parameters:
username- the userpassword- the user's passwordauthType- authentication typerealm- authentication realm
-
addRequestHeader
addRequestHeaderadds a request header to this request. If a request header of the same name already exists, the new value, will be added to the set of already existing values. NOTE: that header names are not case-sensitive.- Overrides:
addRequestHeaderin classHttpRequest- Parameters:
headerName- request header nameheaderValue- request header value
-
addRequestHeader
- Overrides:
addRequestHeaderin classHttpRequest
-
setRequestHeader
setRequestHeadersets a request header for this request overwritting any previously existing header/values with the same name. NOTE: Header names are not case-sensitive.- Overrides:
setRequestHeaderin classHttpRequest- Parameters:
headerName- request header nameheaderValue- request header value
-
setFollowRedirects
public void setFollowRedirects(boolean followRedirects) setFollowRedirectsindicates whether HTTP redirects are followed. By default, redirects are not followed.- Overrides:
setFollowRedirectsin classHttpRequest
-
getFollowRedirects
public boolean getFollowRedirects()getFollowRedirectsindicates whether HTTP redirects are followed.- Overrides:
getFollowRedirectsin classHttpRequest
-
setState
public void setState(org.apache.commons.httpclient.HttpState state) setStatewill set the HTTP state for the current request (i.e. session tracking). This has the side affect- Overrides:
setStatein classHttpRequest
-
execute
executewill dispatch the current request to the target server.- Overrides:
executein classHttpRequest- Returns:
- HttpResponse the server's response.
- Throws:
IOException- if an I/O error occurs during dispatch.org.apache.commons.httpclient.HttpException
-
getState
public org.apache.commons.httpclient.HttpState getState()Returns the current state for this request.- Overrides:
getStatein classHttpRequest- Returns:
- HttpState current state
-
toString
- Overrides:
toStringin classHttpRequest
-