public class HttpOp extends Object
For HTTP GET, the application supplies a URL, the accept header string, and a list of handlers to deal with different content type responses.
For HTTP POST, the application supplies a URL, content, the accept header string, and a list of handlers to deal with different content type responses, or no response is expected.
For HTTP PUT, the application supplies a URL, content, the accept header string
Constructor and Description |
---|
HttpOp() |
Modifier and Type | Method and Description |
---|---|
static String |
execHttpGet(String url,
org.apache.http.protocol.HttpContext httpContext)
Simple GET - no content negotiation
|
static TypedInputStreamHttp |
execHttpGet(String url,
String acceptHeader,
org.apache.http.protocol.HttpContext httpContext)
GET
|
static void |
execHttpGet(String url,
String acceptHeader,
Map<String,HttpResponseHandler> handlers,
org.apache.http.protocol.HttpContext httpContext)
GET
|
static void |
execHttpPost(String url,
org.apache.http.HttpEntity provider,
String acceptType,
Map<String,HttpResponseHandler> handlers,
org.apache.http.protocol.HttpContext context)
POST with response body.
|
static void |
execHttpPost(String url,
String contentType,
ContentProducer provider,
String acceptType,
Map<String,HttpResponseHandler> handlers)
POST with response body
|
static void |
execHttpPost(String url,
String contentType,
InputStream input,
long length)
POST without response body.
|
static void |
execHttpPost(String url,
String contentType,
InputStream input,
long length,
String acceptType,
Map<String,HttpResponseHandler> handlers)
POST with response body.
|
static void |
execHttpPost(String url,
String contentType,
String content)
POST a string without response body.
|
static void |
execHttpPost(String url,
String contentType,
String content,
String acceptType,
Map<String,HttpResponseHandler> handlers,
org.apache.http.protocol.HttpContext httpContext)
POST a string, expect a response body.
|
static void |
execHttpPostForm(String url,
Params params,
Map<String,HttpResponseHandler> handlers)
Execute an HTTP POST form operation
|
static void |
execHttpPostForm(String url,
Params params,
Map<String,HttpResponseHandler> handlers,
org.apache.http.protocol.HttpContext httpContext)
Execute an HTTP POST form operation
|
static void |
execHttpPut(String url,
org.apache.http.HttpEntity entity,
org.apache.http.protocol.HttpContext httpContext)
Execute an HTTP PUT operation
|
static void |
execHttpPut(String url,
String contentType,
InputStream input,
long length,
org.apache.http.protocol.HttpContext httpContext)
Execute an HTTP PUT operation
|
static void |
execHttpPut(String url,
String contentType,
String content,
org.apache.http.protocol.HttpContext httpContext)
Execute an HTTP PUT operation
|
public static void execHttpGet(String url, String acceptHeader, Map<String,HttpResponseHandler> handlers, org.apache.http.protocol.HttpContext httpContext)
The acceptHeader string is any legal value for HTTP Accept: field.
The handlers are the set of content types (without charset), used to dispatch the response body for handling.
A Map entry of ("*",....) is used "no handler found".
HTTP responses 400 and 500 become exceptions.
public static TypedInputStreamHttp execHttpGet(String url, String acceptHeader, org.apache.http.protocol.HttpContext httpContext)
The acceptHeader string is any legal value for HTTP Accept: field.
public static String execHttpGet(String url, org.apache.http.protocol.HttpContext httpContext)
public static void execHttpPost(String url, String contentType, String content)
Execute an HTTP POST, with the string as content.
No response content expected or processed.
public static void execHttpPost(String url, String contentType, InputStream input, long length)
Execute an HTTP POST, with the string as content.
No response content expected or processed.
public static void execHttpPost(String url, String contentType, String content, String acceptType, Map<String,HttpResponseHandler> handlers, org.apache.http.protocol.HttpContext httpContext)
Additional headers e.g. for authentication can be injected through an
HttpContext
.
public static void execHttpPost(String url, String contentType, InputStream input, long length, String acceptType, Map<String,HttpResponseHandler> handlers)
public static void execHttpPost(String url, String contentType, ContentProducer provider, String acceptType, Map<String,HttpResponseHandler> handlers)
public static void execHttpPost(String url, org.apache.http.HttpEntity provider, String acceptType, Map<String,HttpResponseHandler> handlers, org.apache.http.protocol.HttpContext context)
The content for the POST body comes from the HttpEntity.
The response is handled by the handler map, as per execHttpGet(String, String, Map, HttpContext)
Additional headers e.g. for authentication can be injected through an HttpContext
public static void execHttpPostForm(String url, Params params, Map<String,HttpResponseHandler> handlers)
public static void execHttpPostForm(String url, Params params, Map<String,HttpResponseHandler> handlers, org.apache.http.protocol.HttpContext httpContext)
public static void execHttpPut(String url, String contentType, String content, org.apache.http.protocol.HttpContext httpContext)
public static void execHttpPut(String url, String contentType, InputStream input, long length, org.apache.http.protocol.HttpContext httpContext)
public static void execHttpPut(String url, org.apache.http.HttpEntity entity, org.apache.http.protocol.HttpContext httpContext)
Licenced under the Apache License, Version 2.0