public static class HttpStream.Options
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CHARSET_ISO88591
Charset encoding ISO-8859-1
|
static java.lang.String |
CHARSET_UTF8
Charset encoding UTF-8
|
java.lang.String |
data
Set this with your POST/PUT/PATCH/DELETE commands.
|
java.lang.String |
dataPrefix
Set this with your POST/PUT/PATCH/DELETE commands.
|
java.lang.StringBuffer |
dataSB
Set this with your POST/PUT/PATCH/DELETE commands.
|
java.lang.String |
dataSuffix
Set this with your POST/PUT/PATCH/DELETE commands.
|
boolean |
doGet
Deprecated.
Use httpType instead
|
boolean |
doPost
Deprecated.
Use httpType instead
|
java.lang.String |
httpType
Defines the http type that will be used.
|
int |
openTimeOut
The timeout to open.
|
java.lang.String |
postData
Deprecated.
|
java.lang.StringBuffer |
postDataSB
Deprecated.
|
Hashtable |
postHeaders
The headers used in POST.
|
java.lang.String |
postPrefix
Deprecated.
|
java.lang.String |
postSuffix
Deprecated.
|
java.lang.String |
proxyAddress
Basic support for proxy servers on HttpStream.
|
int |
proxyPort
Associated to the proxyAddress,
proxyPort must match your proxy's port.
|
int |
readTimeOut
The read timeout.
|
Hashtable |
requestHeaders
HTTP request headers.
|
protected boolean |
sendData |
SocketFactory |
socketFactory
Socket factory used to create the underlying connection.
|
int |
writeBytesSize
Number of bytes to write at once.
|
int |
writeTimeOut
The write timeout.
|
Constructor and Description |
---|
Options()
Constructs a new Options class, from where you change the behaviour of an Http connection.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getCharsetEncoding()
Returns the currently set charset encoding.
|
boolean |
mustSendData() |
void |
setBasicAuthentication(java.lang.String user,
java.lang.String password)
Base64 encodes the username and password given for basic server authentication
|
void |
setBasicProxyAuthorization(java.lang.String user,
java.lang.String password)
Encodes the given username and password in Base64 for basic proxy authorization
|
void |
setCharsetEncoding(java.lang.String encoding)
Sets the charset encoding to be used by HttpStream.
|
void |
setContent(Multipart multipart)
Set the given MIME multipart to be used as the HttpStream POST data.
This method may not be used with post data fields. |
void |
setContentType(java.lang.String newContentType)
Replaces the default Content-Type (
application/x-www-form-urlencoded ) by the given one. |
void |
setCookies(Hashtable cookies)
Sets the cookies to the ones stored in the given Hashtable.
|
void |
setSendData(boolean sendData) |
public java.lang.String proxyAddress
There is yet the SSL part and the "don't use proxy for these address" part. I'm not interested in doing it, but a good resource is: http://www.innovation.ch/java/HTTPClient/advanced_info.html#proxies
I've just tested on my work proxy, using a bluetooth connection, so I'm not sure if it will work with other proxies.
public int proxyPort
public Hashtable requestHeaders
host
, appended later, is all lower-case.@Deprecated public java.lang.String postData
postPrefix
,
postSuffix
,
postDataSB
@Deprecated public java.lang.StringBuffer postDataSB
postPrefix
,
postSuffix
@Deprecated public java.lang.String postPrefix
postSuffix
,
postData
,
postDataSB
@Deprecated public java.lang.String postSuffix
postPrefix
,
postData
,
postDataSB
public java.lang.String data
dataPrefix
,
postSuffix
,
dataSB
public java.lang.StringBuffer dataSB
dataPrefix
,
postSuffix
public java.lang.String dataPrefix
postSuffix
,
data
,
dataSB
public java.lang.String dataSuffix
dataPrefix
,
data
,
dataSB
public Hashtable postHeaders
public int readTimeOut
public int writeTimeOut
public int openTimeOut
@Deprecated public boolean doGet
@Deprecated public boolean doPost
String conn = hostUrl+"survey/RequestArticle.aspx"; HttpStream.Options options = new HttpStream.Options(); options.readTimeOut = 60000; // 1 minute options.writeTimeOut = 50000; // 50 seconds options.openTimeOut = 120000; // 2 minutes options.doPost = true; options.postData = "xml="; XmlReadableSocket stream = new XmlReadableSocket(new URI(conn),options);
public java.lang.String httpType
String conn = hostUrl+"survey/RequestArticle.aspx"; HttpStream.Options options = new HttpStream.Options(); options.readTimeOut = 60000; // 1 minute options.writeTimeOut = 50000; // 50 seconds options.openTimeOut = 120000; // 2 minutes options.httpType = HttpStream.POST; options.postData = "xml=The default type is GET. You can also define a custom type, like if you want to use restful services. In this case, the header will be set to what you store in the httpType String. Note that, to use another http method, append a space."; XmlReadableSocket stream = new XmlReadableSocket(new URI(conn),options);
HttpStream.Options options = new HttpStream.Options(); options.httpType = "PUT ";*
HttpStream.Options options = new HttpStream.Options(); options.httpType = "CUSTOMMETHOD ";
HttpStream.GET
,
HttpStream.POST
,
HttpStream.PUT
,
HttpStream.PATCH
,
#
public int writeBytesSize
public SocketFactory socketFactory
public static final java.lang.String CHARSET_ISO88591
public static final java.lang.String CHARSET_UTF8
protected boolean sendData
public Options()
postHeaders
to:
Content-Type: application/x-www-form-urlencoded User-Agent: platform / deviceIdYou can override these if you want, just put the new values in the Hashtable or use other methods available in this class.
public void setCharsetEncoding(java.lang.String encoding)
encoding
- the cjarset encoding to be set. Must be either "ISO-8859-1" or "UTF-8".public java.lang.String getCharsetEncoding()
public void setContentType(java.lang.String newContentType)
application/x-www-form-urlencoded
) by the given one.public void setCookies(Hashtable cookies)
public void setBasicAuthentication(java.lang.String user, java.lang.String password)
user
- The username for the server. Passing null disables authentication.password
- The password for the username account on the server. Passing null disables authentication.public void setBasicProxyAuthorization(java.lang.String user, java.lang.String password)
user
- the username for the proxy. Passing null disables proxy authorization.password
- the password for the proxy. Passing null disables proxy authorization.public void setContent(Multipart multipart)
multipart
- the multipart to be set as POST datapublic void setSendData(boolean sendData)
public boolean mustSendData()