org.openjena.riot.web
Class HttpOp

java.lang.Object
  extended by org.openjena.riot.web.HttpOp

public class HttpOp
extends Object

Simplified HTTP operations; simplification means only supporting certain needed uses of HTTP. The expectation is that the simplified operations in this class can be used by other code to generate more application specific HTTP interactions (e.g. SPARQL queries).

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.

See Also:
HttpNames, for HTTP related constants, WebContent, for content type name constants

Constructor Summary
HttpOp()
           
 
Method Summary
static void execHttpGet(String url, String acceptHeader, Map<String,HttpResponseHandler> handlers)
          GET
static void execHttpPost(String url, org.apache.http.HttpEntity provider, String acceptType, Map<String,HttpResponseHandler> handlers)
          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, int length)
          POST without response body.
static void execHttpPost(String url, String contentType, InputStream input, int 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)
          POST a string, expect a response body.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpOp

public HttpOp()
Method Detail

execHttpGet

public static void execHttpGet(String url,
                               String acceptHeader,
                               Map<String,HttpResponseHandler> handlers)
GET

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.


execHttpPost

public static void execHttpPost(String url,
                                String contentType,
                                String content)
POST a string without response body.

Execute an HTTP POST, with the string as content.

No response content expected or processed.


execHttpPost

public static void execHttpPost(String url,
                                String contentType,
                                InputStream input,
                                int length)
POST without response body. Content read from the the input stream.

Execute an HTTP POST, with the string as content.

No response content expected or processed.


execHttpPost

public static void execHttpPost(String url,
                                String contentType,
                                String content,
                                String acceptType,
                                Map<String,HttpResponseHandler> handlers)
POST a string, expect a response body.


execHttpPost

public static void execHttpPost(String url,
                                String contentType,
                                InputStream input,
                                int length,
                                String acceptType,
                                Map<String,HttpResponseHandler> handlers)
POST with response body. The input stream is assumed to be UTF-8.


execHttpPost

public static void execHttpPost(String url,
                                String contentType,
                                ContentProducer provider,
                                String acceptType,
                                Map<String,HttpResponseHandler> handlers)
POST with response body


execHttpPost

public static void execHttpPost(String url,
                                org.apache.http.HttpEntity provider,
                                String acceptType,
                                Map<String,HttpResponseHandler> handlers)
POST with response body.

The content for the POST body comes from the HttpEntity.

The response is handled bythe handler map, as per execHttpGet(String, String, Map)



Licenced under the Apache License, Version 2.0