use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.QueryStringEncoder in project jocean-http by isdom.
the class MessageUtil method addQueryParam.
public static Action1<Object> addQueryParam(final String... nvs) {
return new Action1<Object>() {
@Override
public void call(final Object obj) {
if (obj instanceof HttpRequest) {
final HttpRequest request = (HttpRequest) obj;
if (nvs.length > 0) {
final QueryStringEncoder encoder = new QueryStringEncoder(request.uri());
int idx = 0;
while (idx + 1 < nvs.length) {
encoder.addParam(nvs[idx], nvs[idx + 1]);
idx += 2;
}
request.setUri(encoder.toString());
}
}
}
};
}
use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.QueryStringEncoder in project moco by dreamhead.
the class DefaultHttpRequest method toFullHttpRequest.
public FullHttpRequest toFullHttpRequest() {
ByteBuf buffer = Unpooled.buffer();
MessageContent content = getContent();
if (content != null) {
buffer.writeBytes(content.getContent());
}
QueryStringEncoder encoder = new QueryStringEncoder(uri);
for (Map.Entry<String, String[]> entry : queries.entrySet()) {
String[] values = entry.getValue();
for (String value : values) {
encoder.addParam(entry.getKey(), value);
}
}
FullHttpRequest request = new DefaultFullHttpRequest(HttpVersion.valueOf(getVersion().text()), io.netty.handler.codec.http.HttpMethod.valueOf(method.name()), encoder.toString(), buffer);
for (Map.Entry<String, String[]> entry : getHeaders().entrySet()) {
String key = entry.getKey();
for (String value : entry.getValue()) {
request.headers().add(key, value);
}
}
return request;
}
use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.QueryStringEncoder in project traccar by tananaev.
the class OrbcommProtocolPoller method sendRequest.
@Override
protected void sendRequest(Channel channel, SocketAddress remoteAddress) {
QueryStringEncoder encoder = new QueryStringEncoder("/GLGW/2/RestMessages.svc/JSON/get_return_messages/");
encoder.addParam("access_id", accessId);
encoder.addParam("password", password);
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
encoder.addParam("start_utc", dateFormat.format(startTime));
HttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, encoder.toString(), Unpooled.buffer());
request.headers().add(HttpHeaderNames.HOST, host);
request.headers().add(HttpHeaderNames.CONTENT_LENGTH, 0);
channel.writeAndFlush(request);
}
use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.QueryStringEncoder in project zipkin by openzipkin.
the class BulkCallBuilder method build.
/**
* Creates a bulk request when there is more than one object to store
*/
public HttpCall<Void> build() {
QueryStringEncoder urlBuilder = new QueryStringEncoder("/_bulk");
if (pipeline != null)
urlBuilder.addParam("pipeline", pipeline);
if (waitForRefresh)
urlBuilder.addParam("refresh", "wait_for");
ByteBufAllocator alloc = RequestContext.mapCurrent(RequestContext::alloc, () -> PooledByteBufAllocator.DEFAULT);
HttpCall.RequestSupplier request = new BulkRequestSupplier(entries, shouldAddType, RequestHeaders.of(HttpMethod.POST, urlBuilder.toString(), HttpHeaderNames.CONTENT_TYPE, MediaType.JSON_UTF_8), alloc);
return http.newCall(request, CHECK_FOR_ERRORS, tag);
}
Aggregations