Package org.gcube.common.gxhttp.request
Class GXHTTPStreamRequest
- java.lang.Object
-
- org.gcube.common.gxhttp.request.GXHTTPStreamRequest
-
- All Implemented Interfaces:
GXHTTP<InputStream,HttpURLConnection>
public class GXHTTPStreamRequest extends Object implements GXHTTP<InputStream,HttpURLConnection>
A context-aware request to a web application. It supports sending streams through Put/Post requests.- Author:
- Manuele Simi (ISTI CNR)
-
-
Field Summary
Fields Modifier and Type Field Description protected GXHTTPRequestBuilderbuilderprotected static org.slf4j.Loggerlogger
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Clear up the request.HttpURLConnectionconnect()HttpURLConnectiondelete()GXHTTPStreamRequestfrom(String agent)HttpURLConnectionget()HttpURLConnectionhead()GXHTTPStreamRequestheader(String name, String value)voidisExternalCall(boolean ext)static GXHTTPStreamRequestnewRequest(String address)Creates a new request.HttpURLConnectionoptions()HttpURLConnectionpatch()GXHTTPStreamRequestpath(String path)HttpURLConnectionpost()HttpURLConnectionpost(InputStream body)Sends the POST request to the web application.HttpURLConnectionput()HttpURLConnectionput(InputStream body)Sends the PUT request to the web application.GXHTTPStreamRequestqueryParams(Map<String,String> queryParams)voidsetSecurityToken(String token)HttpURLConnectiontrace()
-
-
-
Field Detail
-
logger
protected static final org.slf4j.Logger logger
-
builder
protected GXHTTPRequestBuilder builder
-
-
Method Detail
-
newRequest
public static GXHTTPStreamRequest newRequest(String address)
Creates a new request.- Parameters:
address- the address of the web app to call- Returns:
- the request
-
put
public HttpURLConnection put(InputStream body) throws Exception
Description copied from interface:GXHTTPSends the PUT request to the web application.- Specified by:
putin interfaceGXHTTP<InputStream,HttpURLConnection>- Parameters:
body- the body of the request- Returns:
- the response
- Throws:
Exception
-
post
public HttpURLConnection post(InputStream body) throws Exception
Description copied from interface:GXHTTPSends the POST request to the web application.- Specified by:
postin interfaceGXHTTP<InputStream,HttpURLConnection>- Parameters:
body- the body of the request- Returns:
- the response
- Throws:
Exception
-
from
public GXHTTPStreamRequest from(String agent)
- Parameters:
agent-- Returns:
- the request
-
path
public GXHTTPStreamRequest path(String path) throws UnsupportedEncodingException
- Parameters:
path-- Returns:
- the request
- Throws:
UnsupportedEncodingException
-
header
public GXHTTPStreamRequest header(String name, String value)
- Parameters:
name-value-- Returns:
- the request
-
queryParams
public GXHTTPStreamRequest queryParams(Map<String,String> queryParams) throws UnsupportedEncodingException
- Parameters:
queryParams-- Returns:
- the request
- Throws:
UnsupportedEncodingException
-
put
public HttpURLConnection put() throws Exception
- Throws:
Exception
-
delete
public HttpURLConnection delete() throws Exception
- Throws:
Exception
-
head
public HttpURLConnection head() throws Exception
- Throws:
Exception
-
get
public HttpURLConnection get() throws Exception
- Throws:
Exception
-
post
public HttpURLConnection post() throws Exception
- Throws:
Exception
-
trace
public HttpURLConnection trace() throws Exception
- Throws:
Exception
-
patch
public HttpURLConnection patch() throws Exception
- Throws:
Exception
-
options
public HttpURLConnection options() throws Exception
- Throws:
Exception
-
connect
public HttpURLConnection connect() throws Exception
- Throws:
Exception
-
setSecurityToken
public void setSecurityToken(String token)
-
isExternalCall
public void isExternalCall(boolean ext)
-
clear
public void clear()
Clear up the request.
-
-