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 void
httpDelete
(String url) DELETEstatic void
httpDelete
(HttpClient httpClient, String url) DELETEstatic TypedInputStream
Perform an HTTP GET to a URL, with "Accept" header "*/*".static TypedInputStream
Perform an HTTP GET to a URL.static TypedInputStream
httpGet
(HttpClient httpClient, String url) Perform an HTTP GET to a URL.static TypedInputStream
httpGet
(HttpClient httpClient, String url, String acceptHeader) Perform an HTTP GET to a URL.static void
httpGetDiscard
(String url) Perform an HTTP and discard the body.static JsonValue
httpGetJson
(String url) static String
httpGetString
(String url) Perform an HTTP and return the body as a string, Return null for a "404 Not Found".static String
httpGetString
(String url, String acceptHeader) Perform an HTTP and return the body as a string, Return null for a "404 Not Found".static String
httpGetString
(HttpClient httpClient, String url) Perform an HTTP and return the body as a string.static String
httpGetString
(HttpClient httpClient, String url, String acceptHeader) Perform an HTTP and return the body as a string.static String
httpGetStringEx
(String url) Perform an HTTP and return the body as a string.static String
HEAD request, return the Content-Type (if any).static String
HEAD request, return the Content-Type (if any).static String
httpHead
(HttpClient httpClient, String url) HEAD request, return the Content-Type (if any).static String
httpHead
(HttpClient httpClient, String url, String acceptHeader) HEAD request, return the Content-Type (if any).static String
httpOptions
(String url) OPTIONS.static String
httpOptions
(HttpClient httpClient, String url) OPTIONS.static void
httpPatch
(String url, String contentType, HttpRequest.BodyPublisher body) PATCHstatic void
httpPatch
(HttpClient httpClient, String url, String contentType, HttpRequest.BodyPublisher body) PATCHstatic void
POSTstatic void
POST to a URL with content=type and string.static void
httpPost
(String url, String contentType, HttpRequest.BodyPublisher body) POSTstatic void
httpPost
(HttpClient httpClient, String url, String contentType, HttpRequest.BodyPublisher body) POSTstatic void
httpPostForm
(String url, Params params) POST params as a HTML form.static TypedInputStream
httpPostForm
(String url, Params params, String acceptString) POST params as a HTML form.static JsonValue
httpPostRtnJSON
(String url) static String
httpPostRtnString
(String url) POST (without a body) - like httpGetString but uses POST - expects a response.static String
httpPostRtnString
(HttpClient httpClient, String url) POST (without a body) - like httpGetString but uses POST - expects a response.static TypedInputStream
httpPostStream
(String url) POST - the application MUST close the InputStream.static TypedInputStream
httpPostStream
(String url, String acceptHeader) POST - the application MUST close the InputStream.static TypedInputStream
httpPostStream
(String url, String contentType, String bodyContent) POST - the application MUST close the InputStream.static TypedInputStream
httpPostStream
(String url, String contentType, HttpRequest.BodyPublisher bodyContent) POST - the application MUST close the InputStream.static TypedInputStream
httpPostStream
(String url, String contentType, HttpRequest.BodyPublisher bodyContent, String acceptHeader) POST - the application MUST close the InputStream.static TypedInputStream
httpPostStream
(HttpClient httpClient, String url) POST - the application MUST close the InputStream.static TypedInputStream
httpPostStream
(HttpClient httpClient, String url, String acceptHeader) POST - the application MUST close the InputStream.static TypedInputStream
httpPostStream
(HttpClient httpClient, String url, String contentType, HttpRequest.BodyPublisher bodyContent) POST - the application MUST close the InputStream.static TypedInputStream
httpPostStream
(HttpClient httpClient, String url, String contentType, HttpRequest.BodyPublisher bodyContent, String acceptHeader) POST - the application MUST close the InputStream.static void
httpPut
(String url, String contentType, HttpRequest.BodyPublisher body) PUTstatic void
httpPut
(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. ThrowsHttpException
on 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 ThrowsHttpException
on 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. ThrowHttpException
for any response that is not 2xx. -
httpHead
HEAD request, return the Content-Type (if any). Return null for success (200) but no content type. ThrowHttpException
for any response that is not 2xx. -
httpHead
HEAD request, return the Content-Type (if any). Return null for success (200) but no content type. ThrowHttpException
for any response that is not 2xx. -
httpHead
HEAD request, return the Content-Type (if any). Return null for success (200) but no content type. ThrowHttpException
for any response that is not 2xx.
-