public class Http extends Object
Modifier and Type | Field and Description |
---|---|
static int |
CONNECTION_TIMEOUT
Connection timeout in milliseconds.
|
static int |
READ_TIMEOUT
Read timeout in milliseconds.
|
Modifier and Type | Method and Description |
---|---|
static Delete |
delete(String uri)
Executes a DELETE request.
|
static Delete |
delete(String url,
int connectTimeout,
int readTimeout)
Executes a DELETE request.
|
static Get |
get(String url)
Executes a GET request.
|
static Get |
get(String url,
int connectTimeout,
int readTimeout)
Executes a GET request
|
static String |
map2URLEncoded(Map params)
Converts a map to URL- encoded string.
|
static Multipart |
multipart(String url)
Create multipart request
|
static Multipart |
multipart(String url,
int connectTimeout,
int readTimeout)
Create multipart request
|
static Patch |
patch(String uri,
byte[] content)
Executes a PATCH request.
|
static Patch |
patch(String url,
byte[] content,
int connectTimeout,
int readTimeout)
Executes a PATCH request.
|
static Patch |
patch(String uri,
String content)
Executes a PATCH request.
|
static Post |
post(String uri)
Executes a POST request.
|
static Post |
post(String uri,
byte[] content)
Executes a POST request.
|
static Post |
post(String url,
byte[] content,
int connectTimeout,
int readTimeout)
Executes a POST request.
|
static Post |
post(String url,
int connectTimeout,
int readTimeout)
Executes a POST request.
|
static Post |
post(String uri,
String content)
Executes a POST request.
|
static Put |
put(String uri,
byte[] content)
Executes a PUT request.
|
static Put |
put(String url,
byte[] content,
int connectTimeout,
int readTimeout)
Executes a PUT request.
|
static Put |
put(String uri,
String content)
Executes a PUT request.
|
public static final int CONNECTION_TIMEOUT
public static final int READ_TIMEOUT
public static Post post(String uri, String content)
uri
- url of resource.content
- content to be posted.Post
object.public static Post post(String uri)
Http.post("http://example.com/create").param("name1", "val1");
uri
- url of resource.Post
object.public static Post post(String uri, byte[] content)
uri
- url of resource.content
- content to be posted.Post
object.public static Post post(String url, byte[] content, int connectTimeout, int readTimeout)
url
- url of resource.content
- content to be posted.connectTimeout
- connection timeout in milliseconds.readTimeout
- read timeout in milliseconds.Post
object.public static Post post(String url, int connectTimeout, int readTimeout)
Http.post("http://example.com/create").param("name1", "val1");
url
- url of resource.connectTimeout
- connection timeout in milliseconds.readTimeout
- read timeout in milliseconds.Post
object.public static Get get(String url)
url
- url of the resource.Get
object.public static Get get(String url, int connectTimeout, int readTimeout)
url
- url of resource.connectTimeout
- connection timeout in milliseconds.readTimeout
- read timeout in milliseconds.Get
object.public static Put put(String uri, String content)
uri
- url of resource.content
- content to be put.Put
object.public static Put put(String uri, byte[] content)
uri
- uri of resource.content
- content to be put.Put
object.public static Put put(String url, byte[] content, int connectTimeout, int readTimeout)
url
- url of resource.content
- content to be "put"connectTimeout
- connection timeout in milliseconds.readTimeout
- read timeout in milliseconds.Put
object.public static Multipart multipart(String url)
url
- URL to send topublic static Multipart multipart(String url, int connectTimeout, int readTimeout)
url
- URL to send toconnectTimeout
- connect timeoutreadTimeout
- read timeoutpublic static Delete delete(String uri)
uri
- uri of resource to deleteDelete
public static Delete delete(String url, int connectTimeout, int readTimeout)
url
- url of resource to deleteconnectTimeout
- connection timeout in milliseconds.readTimeout
- read timeout in milliseconds.Delete
public static Patch patch(String uri, String content)
uri
- url of resource.content
- content to be posted.Patch
object.public static Patch patch(String uri, byte[] content)
uri
- url of resource.content
- content to be posted.Patch
object.public static Patch patch(String url, byte[] content, int connectTimeout, int readTimeout)
url
- url of resource.content
- content to be posted.connectTimeout
- connection timeout in milliseconds.readTimeout
- read timeout in milliseconds.Patch
object.public static String map2URLEncoded(Map params)
post(String, byte[])
, put(String, String)
and others. It makes it easy
to convert parameters to submit a string:
key=value&key1=value1;
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.
key=value&key1=value1;
Copyright © 2020 JavaLite. All rights reserved.