Class HttpRequest
java.lang.Object
com.sun.ts.tests.common.webclient.http.HttpRequest
Represents an HTTP client Request
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final intBasic authenticationprotected org.apache.commons.httpclient.HttpClientstatic intDefault HTTP port.static final intDefault HTTP SSL port.static final intDigest authencticationstatic final intNo authentication
- 
Constructor SummaryConstructorsConstructorDescriptionHttpRequest(String requestLine, String host, int port) Creates new HttpRequest based of the passed request line.
- 
Method SummaryModifier 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()
- 
Field Details- 
DEFAULT_HTTP_PORTpublic static int DEFAULT_HTTP_PORTDefault HTTP port.
- 
DEFAULT_SSL_PORTpublic static final int DEFAULT_SSL_PORTDefault HTTP SSL port.- See Also:
 
- 
NO_AUTHENTICATIONpublic static final int NO_AUTHENTICATIONNo authentication- See Also:
 
- 
BASIC_AUTHENTICATIONpublic static final int BASIC_AUTHENTICATIONBasic authentication- See Also:
 
- 
DIGEST_AUTHENTICATIONpublic static final int DIGEST_AUTHENTICATIONDigest authenctication- See Also:
 
- 
clientprotected org.apache.commons.httpclient.HttpClient client
 
- 
- 
Constructor Details- 
HttpRequestCreates 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- 
getRequestPathgetRequestPathreturns the request path for this particular request.- Returns:
- String request path
 
- 
getRequestMethodgetRequestMethodreturns the request type, i.e., GET, POST, etc.- Returns:
- String request type
 
- 
isSecureRequestpublic boolean isSecureRequest()isSecureConnection()indicates if the Request is secure or not.- Returns:
- boolean whether Request is using SSL or not.
 
- 
setSecureRequestpublic void setSecureRequest(boolean secure) setSecureRequestconfigures this request to use SSL.- Parameters:
- secure- - whether the Request uses SSL or not.
 
- 
setContentsetContentwill 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.- Parameters:
- content- request content
 
- 
setAuthenticationCredentialspublic void setAuthenticationCredentials(String username, String password, int authType, String realm) setAuthenticationCredentials configures the request to perform authentication.usernameandpasswordcannot be null. It is legal forrealmto be null.- Parameters:
- username- the user
- password- the user's password
- authType- authentication type
- realm- authentication realm
 
- 
addRequestHeaderaddRequestHeaderadds 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.- Parameters:
- headerName- request header name
- headerValue- request header value
 
- 
addRequestHeader
- 
setRequestHeadersetRequestHeadersets a request header for this request overwritting any previously existing header/values with the same name. NOTE: Header names are not case-sensitive.- Parameters:
- headerName- request header name
- headerValue- request header value
 
- 
setFollowRedirectspublic void setFollowRedirects(boolean followRedirects) setFollowRedirectsindicates whether HTTP redirects are followed. By default, redirects are not followed.
- 
getFollowRedirectspublic boolean getFollowRedirects()getFollowRedirectsindicates whether HTTP redirects are followed.
- 
setStatepublic 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
- 
executeexecutewill dispatch the current request to the target server.- Returns:
- HttpResponse the server's response.
- Throws:
- IOException- if an I/O error occurs during dispatch.
- org.apache.commons.httpclient.HttpException
 
- 
getStatepublic org.apache.commons.httpclient.HttpState getState()Returns the current state for this request.- Returns:
- HttpState current state
 
- 
toString
 
-