Package com.pnfsoftware.jeb.util.net
Interface INet
- All Known Implementing Classes:
Net
public interface INet
Convenience network utility interface to issue common GET/POST (http or https) queries that
return text contents. The primary network utility class in this package implements this
interface.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionlongdownloadBinary(File dstfile, String url, Map<String, String> urlParams, Map<String, String> serverHeaders, IProgressCallback progressCallback) Download a binary and dump it to disk.Duplicate this object to perform safe parameter update.intintintpost(String url, Map<String, String> urlParams, Map<String, String> bodyParams, Map<String, String> serverHeaders) Perform an http POST request to send a simple form.postMultipart(String url, Map<String, String> formParams, Map<String, FormFileEntry> formFiles) postMultipart(String url, Map<String, String> formParams, Map<String, FormFileEntry> formFiles, Map<String, String> serverHeaders) Perform an http POST request to send a form using themultipart/form-dataencoding.Perform an http GET request.Perform an http GET request.byte[]queryBinary(String url) Perform an http GET request.byte[]queryBinary(String url, Map<String, String> parameters) byte[]Perform an http GET request.byte[]queryBinary(String url, Map<String, String> urlParams, Map<String, String> serverHeaders, IProgressCallback progressCallback) Perform an http GET request.voidsetConnectTimeout(int timeout) voidsetReadTimeout(int timeout) voidvoidsetUserAgent(String userAgent) voidsetWriteTimeout(int timeout)
-
Method Details
-
setUserAgent
- Parameters:
userAgent- a user-agent
-
getUserAgent
String getUserAgent()- Returns:
- the user-agent
-
setConnectTimeout
void setConnectTimeout(int timeout) - Parameters:
timeout- in milliseconds
-
getConnectTimeout
int getConnectTimeout()- Returns:
- timeout in milliseconds
-
setReadTimeout
void setReadTimeout(int timeout) - Parameters:
timeout- timeout in milliseconds
-
getReadTimeout
int getReadTimeout()- Returns:
- timeout in milliseconds
-
setWriteTimeout
void setWriteTimeout(int timeout) - Parameters:
timeout- timeout in milliseconds
-
getWriteTimeout
int getWriteTimeout()- Returns:
- timeout in milliseconds
-
getSecureSocketInfo
SecureSocketInfo getSecureSocketInfo()- Returns:
-
setSecureSocketInfo
- Parameters:
info-
-
duplicate
INet duplicate()Duplicate this object to perform safe parameter update.- Returns:
- a new net object with the same properties as this object (timeouts, user-agent, etc.)
-
query
String query(String url, Map<String, String> parameters, Map<String, throws IOExceptionString> serverHeaders) Perform an http GET request.- Parameters:
url- url with optional parametersparameters- optional additional url parametersserverHeaders-- Returns:
- the server response
- Throws:
IOException- on error
-
query
- Parameters:
url-parameters-- Returns:
- Throws:
IOException
-
query
Perform an http GET request.- Parameters:
url- url with optional parameters- Returns:
- the server response
- Throws:
IOException- on error
-
queryBinary
byte[] queryBinary(String url, Map<String, String> urlParams, Map<String, throws IOExceptionString> serverHeaders, IProgressCallback progressCallback) Perform an http GET request.- Parameters:
url-urlParams-serverHeaders-progressCallback- optional listener- Returns:
- the server response
- Throws:
IOException
-
queryBinary
byte[] queryBinary(String url, Map<String, String> parameters, Map<String, throws IOExceptionString> serverHeaders) Perform an http GET request.- Parameters:
url- url with optional parametersparameters- optional additional url parametersserverHeaders-- Returns:
- the server response
- Throws:
IOException- on error
-
queryBinary
- Parameters:
url-parameters-- Returns:
- Throws:
IOException
-
queryBinary
Perform an http GET request.- Parameters:
url- url with optional parameters- Returns:
- the server response
- Throws:
IOException- on error
-
downloadBinary
long downloadBinary(File dstfile, String url, Map<String, String> urlParams, Map<String, throws IOExceptionString> serverHeaders, IProgressCallback progressCallback) Download a binary and dump it to disk. Similar toqueryBinary(String, Map, Map, IProgressCallback), but the downloaded data is not stored and returned, therefore making this method more suitable to download Large files.- Parameters:
dstfile-url-urlParams-serverHeaders-progressCallback- optional listener- Returns:
- the server response
- Throws:
IOException
-
post
String post(String url, Map<String, String> urlParams, Map<String, throws IOExceptionString> bodyParams, Map<String, String> serverHeaders) Perform an http POST request to send a simple form.- Parameters:
url- url with optional parametersurlParams- optional additional url parametersbodyParams- request content parametersserverHeaders-- Returns:
- the server response
- Throws:
IOException- on error
-
post
String post(String url, Map<String, String> urlParams, Map<String, throws IOExceptionString> bodyParams) - Parameters:
url-urlParams-bodyParams-- Returns:
- Throws:
IOException
-
postMultipart
String postMultipart(String url, Map<String, String> formParams, Map<String, throws IOExceptionFormFileEntry> formFiles, Map<String, String> serverHeaders) Perform an http POST request to send a form using themultipart/form-dataencoding.- Parameters:
url- url with optional parametersformParams- optional request content parametersformFiles- optional request content filesserverHeaders-- Returns:
- the server response
- Throws:
IOException- on error
-
postMultipart
String postMultipart(String url, Map<String, String> formParams, Map<String, throws IOExceptionFormFileEntry> formFiles) - Parameters:
url-formParams-formFiles-- Returns:
- Throws:
IOException
-