Class GXConnection
- java.lang.Object
-
- org.gcube.common.gxhttp.reference.GXConnection
-
public class GXConnection extends Object
A remote connection for aGXHTTPStringRequest.- Author:
- Manuele Simi (ISTI-CNR), Luca Frosini (ISTI-CNR)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classGXConnection.HTTPMETHOD
-
Field Summary
Fields Modifier and Type Field Description protected Stringaddressprotected Stringagentstatic StringAPPLICATION_JSON_CHARSET_UTF_8protected static org.slf4j.Loggerloggerstatic StringPARAM_EQUALSstatic StringPARAM_SEPARATORstatic StringPARAM_STARTERprotected Stringpathstatic StringPATH_SEPARATORstatic StringUTF8
-
Constructor Summary
Constructors Constructor Description GXConnection(String address)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddBody(String body)The body of the request.voidaddBodyAsStream(InputStream bodyAsStream)protected voidaddPath(String pathPart)booleanisExtCall()voidreset()Resets the connection.HttpURLConnectionsend(GXConnection.HTTPMETHOD method)Sends the request with the given methodprotected voidsetAgent(String agent)voidsetExtCall(boolean extCall)voidsetPathParameters(String parameters)Sets the path parameters for the connection.voidsetProperty(String name, String value)Adds a property as header.voidsetQueryParameters(String parameters)Sets the query parameters for the connection.
-
-
-
Field Detail
-
APPLICATION_JSON_CHARSET_UTF_8
public static final String APPLICATION_JSON_CHARSET_UTF_8
- See Also:
- Constant Field Values
-
PATH_SEPARATOR
public static final String PATH_SEPARATOR
- See Also:
- Constant Field Values
-
PARAM_STARTER
public static final String PARAM_STARTER
- See Also:
- Constant Field Values
-
PARAM_EQUALS
public static final String PARAM_EQUALS
- See Also:
- Constant Field Values
-
PARAM_SEPARATOR
public static final String PARAM_SEPARATOR
- See Also:
- Constant Field Values
-
UTF8
public static final String UTF8
- See Also:
- Constant Field Values
-
logger
protected static final org.slf4j.Logger logger
-
address
protected final String address
-
path
protected String path
-
agent
protected String agent
-
-
Constructor Detail
-
GXConnection
public GXConnection(String address)
-
-
Method Detail
-
addPath
protected void addPath(String pathPart) throws UnsupportedEncodingException
- Throws:
UnsupportedEncodingException
-
send
public HttpURLConnection send(GXConnection.HTTPMETHOD method) throws Exception
Sends the request with the given method- Parameters:
method-- Returns:
- the connection
- Throws:
Exception
-
setAgent
protected void setAgent(String agent)
- Parameters:
agent-
-
setPathParameters
public void setPathParameters(String parameters)
Sets the path parameters for the connection.- Parameters:
parameters-
-
setQueryParameters
public void setQueryParameters(String parameters)
Sets the query parameters for the connection.- Parameters:
parameters-
-
reset
public void reset()
Resets the connection.
-
addBody
public void addBody(String body)
The body of the request.- Parameters:
body-
-
addBodyAsStream
public void addBodyAsStream(InputStream bodyAsStream)
- Parameters:
bodyAsStream- the stream to set as input
-
setProperty
public void setProperty(String name, String value)
Adds a property as header.- Parameters:
name-value-
-
setExtCall
public void setExtCall(boolean extCall)
- Parameters:
extCall- the extCall to set
-
isExtCall
public boolean isExtCall()
- Returns:
- the extCall
-
-