Search in sources :

Example 11 with Http2Request

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;
}
Also used : Http2Request(com.webpieces.http2.api.dto.highlevel.Http2Request) Http2Header(com.webpieces.http2.api.dto.lowlevel.lib.Http2Header) Map(java.util.Map)

Example 12 with Http2Request

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;
}
Also used : Http2Request(com.webpieces.http2.api.dto.highlevel.Http2Request) Http2Header(com.webpieces.http2.api.dto.lowlevel.lib.Http2Header)

Example 13 with Http2Request

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;
}
Also used : HttpRequest(org.webpieces.httpparser.api.dto.HttpRequest) Http2Request(com.webpieces.http2.api.dto.highlevel.Http2Request)

Example 14 with Http2Request

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;
}
Also used : Http2Request(com.webpieces.http2.api.dto.highlevel.Http2Request) Http2Header(com.webpieces.http2.api.dto.lowlevel.lib.Http2Header) ArrayList(java.util.ArrayList)

Example 15 with Http2Request

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", "");
    }
}
Also used : HttpRequest(org.webpieces.httpparser.api.dto.HttpRequest) DataFrame(com.webpieces.http2.api.dto.lowlevel.DataFrame) Http2Msg(com.webpieces.http2.api.dto.lowlevel.lib.Http2Msg)

Aggregations

Http2Request (com.webpieces.http2.api.dto.highlevel.Http2Request)71 Test (org.junit.Test)39 Http2Response (com.webpieces.http2.api.dto.highlevel.Http2Response)36 StreamWriter (com.webpieces.http2.api.streaming.StreamWriter)36 Http2Header (com.webpieces.http2.api.dto.lowlevel.lib.Http2Header)33 StreamRef (com.webpieces.http2.api.streaming.StreamRef)32 DataWrapper (org.webpieces.data.api.DataWrapper)18 DataFrame (com.webpieces.http2.api.dto.lowlevel.DataFrame)14 MockResponseListener (org.webpieces.http2client.mock.MockResponseListener)14 XFuture (org.webpieces.util.futures.XFuture)13 RequestStreamHandle (com.webpieces.http2.api.streaming.RequestStreamHandle)11 GoAwayFrame (com.webpieces.http2.api.dto.lowlevel.GoAwayFrame)10 MockStreamWriter (org.webpieces.http2client.mock.MockStreamWriter)10 CancelReason (com.webpieces.http2.api.dto.lowlevel.CancelReason)9 Http2Msg (com.webpieces.http2.api.dto.lowlevel.lib.Http2Msg)9 PassedIn (org.webpieces.httpfrontend2.api.mock2.MockHttp2RequestListener.PassedIn)9 InetSocketAddress (java.net.InetSocketAddress)8 Http2Push (com.webpieces.http2.api.dto.highlevel.Http2Push)7 MockStreamWriter (org.webpieces.httpfrontend2.api.mock2.MockStreamWriter)7 Http2HeaderName (com.webpieces.http2.api.dto.lowlevel.lib.Http2HeaderName)6