use of com.webpieces.http2.api.dto.highlevel.Http2Request in project webpieces by deanhiller.
the class HttpsJsonClient method createHttpReq.
public Http2Request createHttpReq(InetSocketAddress apiAddress, String method, String path) {
Http2Request httpReq = new Http2Request();
httpReq.addHeader(new Http2Header(Http2HeaderName.METHOD, method));
httpReq.addHeader(new Http2Header(Http2HeaderName.AUTHORITY, apiAddress.getHostString()));
httpReq.addHeader(new Http2Header(Http2HeaderName.PATH, path));
httpReq.addHeader(new Http2Header(Http2HeaderName.USER_AGENT, "Webpieces Generated API Client"));
// Http2HeaderName.ACCEPT
httpReq.addHeader(new Http2Header(Http2HeaderName.ACCEPT, "application/json"));
httpReq.addHeader(new Http2Header(Http2HeaderName.CONTENT_TYPE, "application/json"));
Map<String, String> headers = (Map<String, String>) Context.get(Context.HEADERS);
for (Map.Entry<String, String> entry : headers.entrySet()) {
httpReq.addHeader(new Http2Header(entry.getKey(), entry.getValue()));
}
return httpReq;
}
use of com.webpieces.http2.api.dto.highlevel.Http2Request in project webpieces by deanhiller.
the class RequestCreator method createHttp2Request.
public static Http2Request createHttp2Request() {
Http2Request request = new Http2Request();
request.setEndOfStream(true);
request.addHeader(new Http2Header(Http2HeaderName.METHOD, "/"));
request.addHeader(new Http2Header(Http2HeaderName.PATH, "/"));
request.addHeader(new Http2Header(Http2HeaderName.AUTHORITY, "myhost.com"));
request.addHeader(new Http2Header(Http2HeaderName.SCHEME, "http"));
return request;
}
use of com.webpieces.http2.api.dto.highlevel.Http2Request in project webpieces by deanhiller.
the class RequestCreator method createHttp1_1Request.
public static HttpRequest createHttp1_1Request() {
Http2Request request = createHttp2Request();
HttpRequest http1Request = Http2ToHttp11.translateRequest(request);
return http1Request;
}
use of com.webpieces.http2.api.dto.highlevel.Http2Request in project webpieces by deanhiller.
the class Http2Requests method createRequest.
public static Http2Request createRequest(int streamId, boolean eos) {
List<Http2Header> headers = new ArrayList<>();
headers.add(new Http2Header(Http2HeaderName.METHOD, "GET"));
headers.add(new Http2Header(Http2HeaderName.AUTHORITY, "somehost.com"));
headers.add(new Http2Header(Http2HeaderName.PATH, "/"));
headers.add(new Http2Header(Http2HeaderName.SCHEME, "http"));
headers.add(new Http2Header(Http2HeaderName.ACCEPT, "*/*"));
headers.add(new Http2Header(Http2HeaderName.ACCEPT_ENCODING, "gzip, deflate"));
headers.add(new Http2Header(Http2HeaderName.USER_AGENT, "webpieces/1.15.0"));
Http2Request request = new Http2Request(headers);
request.setStreamId(streamId);
request.setEndOfStream(eos);
return request;
}
use of com.webpieces.http2.api.dto.highlevel.Http2Request in project webpieces by deanhiller.
the class Layer2Http11Handler method processCorrectly.
private XFuture<Void> processCorrectly(FrontendSocketImpl socket, HttpPayload payload) {
try {
MDC.put("svrSocket", socket.getChannel().getChannelId());
Http2Msg msg = Http11ToHttp2.translate(payload, socket.isForServingHttpsPages());
if (payload instanceof HttpRequest) {
return processInitialPieceOfRequest(socket, (HttpRequest) payload, (Http2Request) msg);
} else if (msg instanceof DataFrame) {
return processData(socket, (DataFrame) msg);
} else {
throw new IllegalArgumentException("payload not supported=" + payload);
}
} finally {
MDC.put("svrSocket", "");
}
}
Aggregations