Class GXConnection
java.lang.Object
org.gcube.common.gxhttp.reference.GXConnection
A remote connection for a
GXHTTPStringRequest.- Author:
- Manuele Simi (ISTI-CNR), Luca Frosini (ISTI-CNR)
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final StringThe address of the remote service.protected StringThe path of the remote service.static final StringThe application/json;charset=UTF-8 content type.protected static final org.slf4j.LoggerThe logger.static final StringThe parameter equals.static final StringThe parameter separator.static final StringThe parameter starter.protected StringThe path of the remote service.static final StringThe path separator.static final StringThe UTF-8 charset. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidThe body of the request.voidaddBodyAsStream(InputStream bodyAsStream) protected voidAdds a path part to the connection.voidreset()Resets the connection.send(GXConnection.HTTPMETHOD method) Sends the request with the given methodprotected voidSets the agent for the connection.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 Details
-
APPLICATION_JSON_CHARSET_UTF_8
The application/json;charset=UTF-8 content type.- See Also:
-
PATH_SEPARATOR
The path separator.- See Also:
-
PARAM_STARTER
The parameter starter.- See Also:
-
PARAM_EQUALS
The parameter equals.- See Also:
-
PARAM_SEPARATOR
The parameter separator.- See Also:
-
UTF8
The UTF-8 charset.- See Also:
-
logger
protected static final org.slf4j.Logger loggerThe logger. -
address
The address of the remote service. -
path
The path of the remote service. -
agent
The path of the remote service.
-
-
Constructor Details
-
GXConnection
Creates a new connection.- Parameters:
address- the address of the remote service
-
-
Method Details
-
addPath
Adds a path part to the connection.- Parameters:
pathPart- the path part to add- Throws:
UnsupportedEncodingException- if the encoding is not supported
-
send
Sends the request with the given method- Parameters:
method- the HTTP method- Returns:
- the connection
- Throws:
Exception- if an error occurs
-
setAgent
Sets the agent for the connection.- Parameters:
agent- the agent
-
setPathParameters
Sets the path parameters for the connection.- Parameters:
parameters- the parameters
-
setQueryParameters
Sets the query parameters for the connection.- Parameters:
parameters- the parameters
-
reset
public void reset()Resets the connection. -
addBody
The body of the request.- Parameters:
body- the body
-
addBodyAsStream
- Parameters:
bodyAsStream- the stream to set as input
-
setProperty
Adds a property as header.- Parameters:
name- the name of the propertyvalue- the value of the property
-