java.lang.Object
org.apache.jena.http.HttpOp
This is a collection of convenience operations for HTTP requests, mostly in
support of RDF handling and common, basic use cases for HTTP. It is not
comprehensive. For more complicated requirements of HTTP, then the
application can use
HttpClient directly.
Authentication can be handled by supplying a HttpClient which
has been built with an Authenticator or for challenge response (basic and digest)
see AuthEnv.
Operations throw HttpException when the response is not 2xx, except for
"httpGetString" and "httpPostRtnString" which return null for a 404 response.
Also supported:
- GET and return a string
- GET and return a JSON structure
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidhttpDelete(String url) DELETEstatic voidhttpDelete(HttpClient httpClient, String url) DELETEstatic TypedInputStreamPerform an HTTP GET to a URL, with "Accept" header "*/*".static TypedInputStreamPerform an HTTP GET to a URL.static TypedInputStreamhttpGet(HttpClient httpClient, String url) Perform an HTTP GET to a URL.static TypedInputStreamhttpGet(HttpClient httpClient, String url, String acceptHeader) Perform an HTTP GET to a URL.static voidhttpGetDiscard(String url) Perform an HTTP and discard the body.static JsonValuehttpGetJson(String url) static StringhttpGetString(String url) Perform an HTTP and return the body as a string, Return null for a "404 Not Found".static StringhttpGetString(String url, String acceptHeader) Perform an HTTP and return the body as a string, Return null for a "404 Not Found".static StringhttpGetString(HttpClient httpClient, String url) Perform an HTTP and return the body as a string.static StringhttpGetString(HttpClient httpClient, String url, String acceptHeader) Perform an HTTP and return the body as a string.static StringhttpGetStringEx(String url) Perform an HTTP and return the body as a string.static StringHEAD request, return the Content-Type (if any).static StringHEAD request, return the Content-Type (if any).static StringhttpHead(HttpClient httpClient, String url) HEAD request, return the Content-Type (if any).static StringhttpHead(HttpClient httpClient, String url, String acceptHeader) HEAD request, return the Content-Type (if any).static StringhttpOptions(String url) OPTIONS.static StringhttpOptions(HttpClient httpClient, String url) OPTIONS.static voidhttpPatch(String url, String contentType, HttpRequest.BodyPublisher body) PATCHstatic voidhttpPatch(HttpClient httpClient, String url, String contentType, HttpRequest.BodyPublisher body) PATCHstatic voidPOSTstatic voidPOST to a URL with content=type and string.static voidhttpPost(String url, String contentType, HttpRequest.BodyPublisher body) POSTstatic voidhttpPost(HttpClient httpClient, String url, String contentType, HttpRequest.BodyPublisher body) POSTstatic voidhttpPostForm(String url, Params params) POST params as a HTML form.static TypedInputStreamhttpPostForm(String url, Params params, String acceptString) POST params as a HTML form.static JsonValuehttpPostRtnJSON(String url) static StringhttpPostRtnString(String url) POST (without a body) - like httpGetString but uses POST - expects a response.static StringhttpPostRtnString(HttpClient httpClient, String url) POST (without a body) - like httpGetString but uses POST - expects a response.static TypedInputStreamhttpPostStream(String url) POST - the application MUST close the InputStream.static TypedInputStreamhttpPostStream(String url, String acceptHeader) POST - the application MUST close the InputStream.static TypedInputStreamhttpPostStream(String url, String contentType, String bodyContent) POST - the application MUST close the InputStream.static TypedInputStreamhttpPostStream(String url, String contentType, HttpRequest.BodyPublisher bodyContent) POST - the application MUST close the InputStream.static TypedInputStreamhttpPostStream(String url, String contentType, HttpRequest.BodyPublisher bodyContent, String acceptHeader) POST - the application MUST close the InputStream.static TypedInputStreamhttpPostStream(HttpClient httpClient, String url) POST - the application MUST close the InputStream.static TypedInputStreamhttpPostStream(HttpClient httpClient, String url, String acceptHeader) POST - the application MUST close the InputStream.static TypedInputStreamhttpPostStream(HttpClient httpClient, String url, String contentType, HttpRequest.BodyPublisher bodyContent) POST - the application MUST close the InputStream.static TypedInputStreamhttpPostStream(HttpClient httpClient, String url, String contentType, HttpRequest.BodyPublisher bodyContent, String acceptHeader) POST - the application MUST close the InputStream.static voidhttpPut(String url, String contentType, HttpRequest.BodyPublisher body) PUTstatic voidhttpPut(HttpClient httpClient, String url, String contentType, HttpRequest.BodyPublisher body) PUT
-
Method Details
-
httpGetString
Perform an HTTP and return the body as a string, Return null for a "404 Not Found". -
httpGetStringEx
Perform an HTTP and return the body as a string. ThrowsHttpExceptionon all non-success HTTP status codes including 404, unlikehttpGetString(String).- Throws:
HttpException
-
httpGetDiscard
Perform an HTTP and discard the body. Only useful to use GET as a ping-like operation on a URL ThrowsHttpExceptionon all non-success HTTP status codes.- Throws:
HttpException
-
httpGetString
Perform an HTTP and return the body as a string, Return null for a "404 Not Found". -
httpGetString
Perform an HTTP and return the body as a string. Return null for a "404 Not Found". -
httpGetString
Perform an HTTP and return the body as a string. Return null for a "404 Not Found". -
httpPostRtnString
POST (without a body) - like httpGetString but uses POST - expects a response. Return null for a "404 Not Found". -
httpPostRtnString
POST (without a body) - like httpGetString but uses POST - expects a response. Return null for a "404 Not Found". -
httpPostForm
POST params as a HTML form. -
httpPostForm
POST params as a HTML form. -
httpPostRtnJSON
-
httpGetJson
-
httpGet
Perform an HTTP GET to a URL, with "Accept" header "*/*". The application MUST close the InputStream. -
httpGet
Perform an HTTP GET to a URL. The application MUST close the InputStream. -
httpGet
Perform an HTTP GET to a URL. The application MUST close the InputStream. -
httpGet
Perform an HTTP GET to a URL. The application MUST close the InputStream. -
httpPost
POST -
httpPost
POST -
httpPost
POST to a URL with content=type and string. -
httpPost
public static void httpPost(HttpClient httpClient, String url, String contentType, HttpRequest.BodyPublisher body) POST -
httpPostStream
POST - the application MUST close the InputStream. -
httpPostStream
POST - the application MUST close the InputStream. -
httpPostStream
POST - the application MUST close the InputStream. -
httpPostStream
public static TypedInputStream httpPostStream(HttpClient httpClient, String url, String acceptHeader) POST - the application MUST close the InputStream. -
httpPostStream
public static TypedInputStream httpPostStream(String url, String contentType, HttpRequest.BodyPublisher bodyContent) POST - the application MUST close the InputStream. -
httpPostStream
POST - the application MUST close the InputStream. -
httpPostStream
public static TypedInputStream httpPostStream(String url, String contentType, HttpRequest.BodyPublisher bodyContent, String acceptHeader) POST - the application MUST close the InputStream. -
httpPostStream
public static TypedInputStream httpPostStream(HttpClient httpClient, String url, String contentType, HttpRequest.BodyPublisher bodyContent) POST - the application MUST close the InputStream. -
httpPostStream
public static TypedInputStream httpPostStream(HttpClient httpClient, String url, String contentType, HttpRequest.BodyPublisher bodyContent, String acceptHeader) POST - the application MUST close the InputStream. -
httpPut
PUT -
httpPut
public static void httpPut(HttpClient httpClient, String url, String contentType, HttpRequest.BodyPublisher body) PUT -
httpPatch
PATCH -
httpPatch
public static void httpPatch(HttpClient httpClient, String url, String contentType, HttpRequest.BodyPublisher body) PATCH -
httpDelete
DELETE -
httpDelete
DELETE -
httpOptions
OPTIONS. Returns the HTTP response "Allow" field string. -
httpOptions
OPTIONS. Returns the HTTP response "Allow" field string. -
httpHead
HEAD request, return the Content-Type (if any). Return null for success (200) but no content type. ThrowHttpExceptionfor any response that is not 2xx. -
httpHead
HEAD request, return the Content-Type (if any). Return null for success (200) but no content type. ThrowHttpExceptionfor any response that is not 2xx. -
httpHead
HEAD request, return the Content-Type (if any). Return null for success (200) but no content type. ThrowHttpExceptionfor any response that is not 2xx. -
httpHead
HEAD request, return the Content-Type (if any). Return null for success (200) but no content type. ThrowHttpExceptionfor any response that is not 2xx.
-