Package javaforce
Class HTTP
java.lang.Object
javaforce.HTTP
- Direct Known Subclasses:
HTTPS
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classstatic classHTTP Parameters.static classPart a of multipart POSTstatic interfaceProgress Listener -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic booleanstatic final StringForm Type for URL encoded data.static final StringForm Type for multipart data (supports files).protected Stringprotected InputStreamprotected OutputStreamstatic final StringPart Type for html text.static final StringPart Type for binary data.static final StringPart Type for plain text.static final StringPart Type for zip file.protected intprotected Socket -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringRemoves user info from HTTP URL.voidClears all request headers.voidclose()Close connection.byte[]HTTP GET using url.booleanget(String url, OutputStream os) HTTP GET using url.intgetCode()Returns last status code.static String[]getContent(String[] msg) Get Content from a HTTP message.Returns reply header.Returns reply headers.static Stringstatic StringgetParameter(String[] params, String name) Returns HTTP style parameter from list of parameters.static String[]getParameters(String[] params, String name) Returns HTTP style parameter(s) from list of parameters.static intHTTP GET using url.static StringgetUserInfo(String urlstr) booleanReturns connection status.static voidTest HTTPbooleanbooleanbyte[]HTTP POST (URL encoded) Returns content as byte[]booleanpost(String url, byte[] data, OutputStream os) HTTP POST (URL encoded) Writes content to OutputStream.booleanpost(String url, byte[] data, OutputStream os, String encType) HTTP POST (URL encoded) Writes content to OutputStream.byte[]HTTP POST (URL encoded) Returns content as byte[]byte[]HTTP POST (multipart/form-data encoded)booleanpost(String url, HTTP.Part[] parts, OutputStream os) HTTP POST (multipart/form-data encoded) Writes content to OutputStream.postString(String url, byte[] data) HTTP POST using url with post data using enctype = application/x-www-form-urlencoded.voidSet Accept header value.voidSet a request header.voidsetProgressListener(HTTP.Progress progress) Registers a download progress listener.static voidsetTimeout(int timeout) Set connect/read timeout in ms (default = 30000)static voidsetUserAgent(String ua) Set User-Agent header value.
-
Field Details
-
s
-
os
-
is
-
host
-
port
protected int port -
debug
public static boolean debug -
formType
Form Type for URL encoded data.- See Also:
-
formTypeMultiPart
Form Type for multipart data (supports files).- See Also:
-
partTypeText
Part Type for plain text.- See Also:
-
partTypeHTML
Part Type for html text.- See Also:
-
partTypeStream
Part Type for binary data.- See Also:
-
partTypeZip
Part Type for zip file.- See Also:
-
-
Constructor Details
-
HTTP
public HTTP()
-
-
Method Details
-
cleanURL
Removes user info from HTTP URL. -
getUserInfo
-
getHost
-
getPort
-
setTimeout
public static void setTimeout(int timeout) Set connect/read timeout in ms (default = 30000) -
open
-
open
-
close
public void close()Close connection. -
isConnected
public boolean isConnected()Returns connection status. -
setProgressListener
Registers a download progress listener. -
setHeader
Set a request header. -
clearHeaders
public void clearHeaders()Clears all request headers. -
getHeader
Returns reply header. -
getHeaders
Returns reply headers. -
getCode
public int getCode()Returns last status code. -
setAccept
Set Accept header value. -
setUserAgent
Set User-Agent header value. -
get
HTTP GET using url. Writes content to OutputStream. -
get
HTTP GET using url. Returns as a byte[] -
getString
HTTP GET using url. Returns as a String. -
post
HTTP POST (multipart/form-data encoded) Writes content to OutputStream. -
post
HTTP POST (multipart/form-data encoded)- Returns:
- content (null on error)
-
post
HTTP POST (URL encoded) Writes content to OutputStream. -
post
HTTP POST (URL encoded) Writes content to OutputStream. -
post
HTTP POST (URL encoded) Returns content as byte[] -
post
HTTP POST (URL encoded) Returns content as byte[] -
postString
HTTP POST using url with post data using enctype = application/x-www-form-urlencoded. Returns content as String. -
main
Test HTTP -
getParameter
Returns HTTP style parameter from list of parameters.- Parameters:
params- = HTTP list of parametersname- = name of parameter to return- Returns:
- parameter
-
getParameters
Returns HTTP style parameter(s) from list of parameters.- Parameters:
params- = HTTP list of parametersname- = name of parameter to return- Returns:
- parameter(s)
-
getContent
Get Content from a HTTP message.
-