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.
|
Constructor and Description |
---|
Http() |
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 |
map2Content(Map params)
Converts a map to URL- encoded content.
|
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 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 int CONNECTION_TIMEOUT
public static 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, 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 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 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 String map2Content(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
content to be posted, such that keys are names of parameters, and values are values of those
posted parameters. This method will also URL-encode keys and content using UTF-8 encoding.
String representations of both keys and values are used.
Post
object.Copyright © 2016 JavaLite. All rights reserved.