|
Secure iNet Factory | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.jscape.inet.mime.MimeMessage
com.jscape.inet.http.HttpRequest
public class HttpRequest
Creates the properties of an HTTP request.
Example Usage:
HttpRequest request = new HttpRequest("http://www.myserver.com","GET"); request.addParameter(new HttpParameter("username","jsmith")); request.addParameter(new HttpParameter("password","secret"));
Field Summary |
---|
Fields inherited from interface com.jscape.inet.mime.MimeConstants |
---|
COLON, CRLF, EQUALS, QUESTION_MARK, SEMI_COLON, SPACE, TAB |
Constructor Summary | |
---|---|
HttpRequest(java.lang.String url)
Creates a new HttpRequest instance using default GET request method. |
|
HttpRequest(java.lang.String url,
java.lang.String method)
Creates a new HttpRequest instance. |
Method Summary | |
---|---|
void |
addCookie(java.lang.String name,
java.lang.String value)
Adds cookie name/value pair to this HttpRequest |
void |
addHeader(MimeHeader header)
Adds MIME header to this HttpRequest . |
void |
addHeader(java.lang.String name,
java.lang.String value)
Adds MIME header to this HttpRequest . |
void |
addParameter(HttpParameter parameter)
Adds a query parameter to HTTP request. |
void |
addParameter(java.lang.String name,
java.lang.String value)
Adds a query parameter to HTTP request. |
void |
addReplaceHeader(MimeHeader header)
Adds MIME header to this HttpRequest , replacing existing header if found. |
void |
addReplaceHeader(java.lang.String name,
java.lang.String value)
Adds MIME header to this HttpRequest , replacing existing header if found. |
void |
addReplaceParameter(HttpParameter parameter)
Adds a query parameter to HTTP request replacing any other parameters with same name. |
void |
addReplaceParameter(java.lang.String name,
java.lang.String value)
Adds a query parameter to HTTP request replacing any other parameters with same name. |
void |
clearCookies()
Clears all cookies from HTTP request |
void |
clearParameters()
Clears all parameters from HTTP request |
java.lang.String |
getHttpVersion()
Gets the HTTP version number sent in this HttpRequest . |
byte[] |
getMessage()
Gets contents of this HttpRequest . |
java.lang.String |
getMethod()
Gets the request method used in HTTP request. |
java.util.Enumeration |
getParameters()
Gets all HTTP parameters to be sent with HTTP request. |
java.lang.String |
getProxyHost()
Gets the hostname/ipaddress of the proxy server responsible for handling HTTP requests. |
int |
getProxyPort()
Gets the port of HTTP proxy server. |
java.lang.String |
getProxyUsername()
Gets the username used in authentication to HTTP proxy server. |
java.lang.String |
getURL()
Gets URL of HTTP request. |
java.lang.String |
getUserAgent()
Gets User-Agent header of HTTP request. |
boolean |
isUTF8()
Gets whether UTF-8 encoding is used when encoding parameters, default is true. |
void |
setBasicAuthentication(java.lang.String username,
java.lang.String password)
Sets username and password to be used in HTTP Basic Authentication. |
void |
setHttpVersion(java.lang.String httpVersion)
Sets the HTTP version number sent in this HttpRequest . |
void |
setMethod(java.lang.String method)
Sets the request method used in HTTP request. |
void |
setProxyHost(java.lang.String proxyHost)
Sets the hostname of the proxy server to be used in HTTP communications. |
void |
setProxyLogin(java.lang.String proxyUsername,
java.lang.String proxyPassword)
Sets the username and password used in authentication to HTTP proxy server. |
void |
setProxyPort(int proxyPort)
Sets the port to be used when communicating with an HTTP proxy server. |
void |
setURL(java.lang.String urlStr)
Sets URL of HTTP request. |
void |
setUserAgent(java.lang.String userAgent)
Sets the User-Agent header of a HTTP request. |
void |
setUTF8(boolean b)
Sets whether UTF-8 encoding is used when encoding parameters, default is true. |
Methods inherited from class com.jscape.inet.mime.MimeMessage |
---|
addPart, getBody, getBodyAsFile, getBodyData, getBoundary, getContentTransferEncoding, getContentType, getHeader, getHeaders, getHeaders, getHeaderValue, getPart, getParts, getRawBodyData, removeHeader, removePart, removeParts, setBody, setBody, setBody, setBody, setBodyAsFile, setContentType |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public HttpRequest(java.lang.String url) throws HttpException
HttpRequest
instance using default GET request method.
Any parameters provided in the URL must be URL encoded
Additional parameters added using addParameter methods will be appended to any
existing parameters in the URL.
url
- the URL to retrieve
HttpException
- if a MIME related error occurspublic HttpRequest(java.lang.String url, java.lang.String method) throws HttpException
HttpRequest
instance.
Any parameters provided in the URL for a GET request must be URL encoded.
Additional parameters added using addParameter methods will be appended to any
existing parameters in the URL.
url
- the URL to retrievemethod
- the request method to use GET or POST
HttpException
- if a MIME related parsing error occursMethod Detail |
---|
public void setProxyHost(java.lang.String proxyHost)
proxyHost
- the hostname or ipaddress of the proxy serverpublic java.lang.String getProxyHost()
public void setProxyPort(int proxyPort)
proxyPort
- port of listening HTTP proxy serverpublic int getProxyPort()
public java.lang.String getProxyUsername()
public void setProxyLogin(java.lang.String proxyUsername, java.lang.String proxyPassword)
proxyUsername
- username used in proxy authenticationproxyPassword
- password used in proxy authenticationpublic void addCookie(java.lang.String name, java.lang.String value)
HttpRequest
name
- the cookie namevalue
- the cookie valuepublic void addHeader(MimeHeader header)
HttpRequest
.
addHeader
in class MimeMessage
header
- a MimeHeader
public void addHeader(java.lang.String name, java.lang.String value) throws MimeException
HttpRequest
.
addHeader
in class MimeMessage
name
- the header namevalue
- the header value
MimeException
- if a MIME related parsing error occurspublic void addReplaceHeader(MimeHeader header)
HttpRequest
, replacing existing header if found.
addReplaceHeader
in class MimeMessage
header
- a MimeHeader
public void addReplaceHeader(java.lang.String name, java.lang.String value) throws MimeException
HttpRequest
, replacing existing header if found.
addReplaceHeader
in class MimeMessage
name
- the header namevalue
- the header value
MimeException
- if a MIME related parsing error occurspublic void addParameter(HttpParameter parameter)
parameter
- the HttpParameter
to addHttpParameter
public void addReplaceParameter(HttpParameter parameter)
parameter
- the HttpParameter to add or replacepublic void addReplaceParameter(java.lang.String name, java.lang.String value)
name
- the name of the parameter to add.value
- the value of the parameter to add.public void addParameter(java.lang.String name, java.lang.String value)
name
- the name of the parameter to add.value
- the value of the parameter to add.public void clearParameters()
public void clearCookies()
public java.util.Enumeration getParameters()
Enumeration
of HttpParameter
HttpParameter
public void setBasicAuthentication(java.lang.String username, java.lang.String password) throws HttpException
username
- the username used in HTTP Basic Authenticationpassword
- the password used in HTTP Basic Authentication
HttpException
- if a MIME related parsing error occurspublic void setUserAgent(java.lang.String userAgent) throws HttpException
userAgent
- the user agent
HttpException
- if a MIME related parsing error occurspublic java.lang.String getUserAgent()
public void setMethod(java.lang.String method)
method
- request method used in HTTP requestpublic java.lang.String getMethod()
public void setURL(java.lang.String urlStr)
urlStr
- the URL of HTTP requestpublic java.lang.String getURL()
public byte[] getMessage() throws MimeException
HttpRequest
. Contents include all
MIME message headers, body and any parts. If request method is POST
then required Content-Type and Content-Length headers are added
automatically unless already defined using
MimeMessage#addHeader
method.
getMessage
in class MimeMessage
MimeException
- if a MIME related error occurs while building message contentsMimeMessage.addHeader(com.jscape.inet.mime.MimeHeader)
public java.lang.String getHttpVersion()
HttpRequest
.
Default value is 1.0
public void setHttpVersion(java.lang.String httpVersion)
HttpRequest
.
Default value is 1.0
httpVersion
- the HTTP version numberpublic boolean isUTF8()
public void setUTF8(boolean b)
b
- true if UTF-8 encoding is enabled, false otherwise
|
Secure iNet Factory | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |