public class HttpRestClientHelper extends Object
Constructor and Description |
---|
HttpRestClientHelper(String baseUri,
int nbclient,
long timeout,
io.netty.channel.ChannelInitializer<io.netty.channel.socket.SocketChannel> Initializer) |
Modifier and Type | Method and Description |
---|---|
void |
closeAll()
Finalize the HttpRestClientHelper
|
io.netty.channel.Channel |
getChannel(String host,
int port)
Create one new connection to the remote host using port
|
static void |
main(String[] args) |
RestFuture |
sendQuery(io.netty.channel.Channel channel,
io.netty.handler.codec.http.HttpMethod method,
String host,
String addedUri,
String user,
Map<String,String> uriArgs,
String json)
Send an HTTP query using the channel for target, but without any
Signature
|
RestFuture |
sendQuery(HmacSha256 hmacSha256,
io.netty.channel.Channel channel,
io.netty.handler.codec.http.HttpMethod method,
String host,
String addedUri,
String user,
String pwd,
Map<String,String> uriArgs,
String json)
Send an HTTP query using the channel for target, using signature
|
public HttpRestClientHelper(String baseUri, int nbclient, long timeout, io.netty.channel.ChannelInitializer<io.netty.channel.socket.SocketChannel> Initializer)
baseUri
- base of all URI, in general simply "/" (default if
null)nbclient
- max number of client connected at oncetimeout
- timeout used in connectionInitializer
- the associated client pipeline factorypublic io.netty.channel.Channel getChannel(String host, int port)
host
- port
- public RestFuture sendQuery(HmacSha256 hmacSha256, io.netty.channel.Channel channel, io.netty.handler.codec.http.HttpMethod method, String host, String addedUri, String user, String pwd, Map<String,String> uriArgs, String json)
hmacSha256
- SHA-256 key to create the signaturechannel
- target of the querymethod
- HttpMethod to usehost
- target of the query (shall be the same as for the
channel)addedUri
- additional uri, added to baseUri (shall include
also
extra arguments) (might be null)user
- user to use in authenticated Rest procedure (might be
null)pwd
- password to use in authenticated Rest procedure (might
be
null)uriArgs
- arguments for Uri if any (might be null)json
- json to send as body in the request (might be null);
Useful
in PUT, POST but should not
in GET, DELETE, OPTIONSpublic RestFuture sendQuery(io.netty.channel.Channel channel, io.netty.handler.codec.http.HttpMethod method, String host, String addedUri, String user, Map<String,String> uriArgs, String json)
channel
- target of the querymethod
- HttpMethod to usehost
- target of the query (shall be the same as for the
channel)addedUri
- additional uri, added to baseUri (shall include
also
extra arguments) (might be null)user
- user to use in authenticated Rest procedure (might be
null)uriArgs
- arguments for Uri if any (might be null)json
- json to send as body in the request (might be null);
Useful
in PUT, POST but should not in
GET, DELETE, OPTIONSpublic void closeAll()
public static void main(String[] args)
args
- as uri (http://host:port/uri method user pwd
sign=path|nosign [json])Copyright © 2009–2020 Waarp. All rights reserved.