Package org.javalite.http
Class Http
java.lang.Object
org.javalite.http.Http
This is a convenience class to allow creation of request objects on one line with some pre-defined values.
- Author:
- Igor Polevoy
-
Field Summary
Modifier and TypeFieldDescriptionstatic int
Connection timeout in milliseconds.static int
Read timeout in milliseconds. -
Method Summary
Modifier and TypeMethodDescriptionstatic Delete
Executes a DELETE request.static Delete
Executes a DELETE request.static Get
Executes a GET request.static Get
Executes a GET requeststatic String
map2URLEncoded(Map params)
Converts a map to URL- encoded string.static Multipart
Create multipart requeststatic Multipart
Create multipart requeststatic Patch
Executes a PATCH request.static Patch
Executes a PATCH request.static Patch
Executes a PATCH request.static Post
Executes a POST request.static Post
Executes a POST request.static Post
Executes a POST request.static Post
Executes a POST request.static Post
Executes a POST request.static Put
static Put
Executes a PUT request.static Put
Executes a PUT request.static Put
Executes a PUT request.
-
Field Details
-
CONNECTION_TIMEOUT
public static final int CONNECTION_TIMEOUTConnection timeout in milliseconds. Set this value to what you like to override default.- See Also:
- Constant Field Values
-
READ_TIMEOUT
public static final int READ_TIMEOUTRead timeout in milliseconds. Set this value to what you like to override default.- See Also:
- Constant Field Values
-
-
Method Details
-
post
Executes a POST request.- Parameters:
uri
- url of resource.content
- content to be posted.- Returns:
Post
object.
-
post
Executes a POST request. Often used to post form parameters:Http.post("http://example.com/create").param("name1", "val1");
- Parameters:
uri
- url of resource.- Returns:
Post
object.
-
post
Executes a POST request.- Parameters:
uri
- url of resource.content
- content to be posted.- Returns:
Post
object.
-
post
Executes a POST request.- Parameters:
url
- url of resource.content
- content to be posted.connectTimeout
- connection timeout in milliseconds.readTimeout
- read timeout in milliseconds.- Returns:
Post
object.
-
post
Executes a POST request. Often used to post form parameters:Http.post("http://example.com/create").param("name1", "val1");
- Parameters:
url
- url of resource.connectTimeout
- connection timeout in milliseconds.readTimeout
- read timeout in milliseconds.- Returns:
Post
object.
-
get
Executes a GET request.- Parameters:
url
- url of the resource.- Returns:
Get
object.
-
get
Executes a GET request- Parameters:
url
- url of resource.connectTimeout
- connection timeout in milliseconds.readTimeout
- read timeout in milliseconds.- Returns:
Get
object.
-
put
Executes a PUT request.- Parameters:
uri
- url of resource.content
- content to be put.- Returns:
Put
object.
-
put
-
put
Executes a PUT request.- Parameters:
uri
- uri of resource.content
- content to be put.- Returns:
Put
object.
-
put
Executes a PUT request.- Parameters:
url
- url of resource.content
- content to be "put"connectTimeout
- connection timeout in milliseconds.readTimeout
- read timeout in milliseconds.- Returns:
Put
object.
-
multipart
Create multipart request- Parameters:
url
- URL to send to- Returns:
- new Multipart request
-
multipart
Create multipart request- Parameters:
url
- URL to send toconnectTimeout
- connect timeoutreadTimeout
- read timeout- Returns:
- new Multipart request
-
delete
Executes a DELETE request.- Parameters:
uri
- uri of resource to delete- Returns:
Delete
-
delete
Executes a DELETE request.- Parameters:
url
- url of resource to deleteconnectTimeout
- connection timeout in milliseconds.readTimeout
- read timeout in milliseconds.- Returns:
Delete
-
patch
Executes a PATCH request.- Parameters:
uri
- url of resource.content
- content to be posted.- Returns:
Patch
object.
-
patch
Executes a PATCH request.- Parameters:
uri
- url of resource.content
- content to be posted.- Returns:
Patch
object.
-
patch
Executes a PATCH request.- Parameters:
url
- url of resource.content
- content to be posted.connectTimeout
- connection timeout in milliseconds.readTimeout
- read timeout in milliseconds.- Returns:
Patch
object.
-
map2URLEncoded
Converts a map to URL- encoded string. This is a convenience method which can be used in combination withpost(String, byte[])
,put(String, String)
and others. It makes it easy to convert parameters to submit a string:key=value&key1=value1;
- Parameters:
params
- map with keys and values to be posted. This map is used to build a URL-encoded string, such that keys are names of parameters, and values are values of those parameters. This method will also URL-encode keys and content using UTF-8 encoding.String representations of both keys and values are used.
- Returns:
- URL-encided string like:
key=value&key1=value1;
-