use of com.webpieces.http2.api.dto.lowlevel.lib.Http2Header in project webpieces by deanhiller.
the class Translations2 method translate.
public static FullResponse translate(HttpFullResponse r) {
Http2Response headers = new Http2Response();
HttpResponse http1Response = r.getResponse();
for (Header http1Header : http1Response.getHeaders()) {
headers.addHeader(new Http2Header(http1Header.getName(), http1Header.getValue()));
}
HttpResponseStatus status = http1Response.getStatusLine().getStatus();
headers.addHeader(new Http2Header(Http2HeaderName.STATUS, "" + status.getCode()));
DataWrapper data = r.getData();
FullResponse http2Response = new FullResponse(headers, data, null);
return http2Response;
}
use of com.webpieces.http2.api.dto.lowlevel.lib.Http2Header in project webpieces by deanhiller.
the class HeaderEncoding method createHeaderFrames.
private List<Http2Frame> createHeaderFrames(HasHeaderFragment initialFrame, List<Http2Header> headers, Encoder encoder, long maxFrameSize) {
int maxSize = (int) maxFrameSize;
if (maxFrameSize > Integer.MAX_VALUE)
throw new IllegalStateException("max frame size too large for this hpack library");
List<Http2Frame> headerFrames = new LinkedList<>();
DataWrapper serializedHeaders = serializeHeaders(encoder, headers);
HasHeaderFragment currentFrame = initialFrame;
HasHeaderFragment lastFrame = currentFrame;
DataWrapper dataLeftOver = serializedHeaders;
while (dataLeftOver.getReadableSize() > 0) {
lastFrame = currentFrame;
int splitSize = Math.min(dataLeftOver.getReadableSize(), maxSize);
List<? extends DataWrapper> split = dataGen.split(dataLeftOver, splitSize);
DataWrapper fragment = split.get(0);
currentFrame.setHeaderFragment(fragment);
headerFrames.add(currentFrame);
currentFrame = new ContinuationFrame();
currentFrame.setStreamId(initialFrame.getStreamId());
dataLeftOver = split.get(1);
}
// last frame is currentFrame so set end header
lastFrame.setEndHeaders(true);
return headerFrames;
}
use of com.webpieces.http2.api.dto.lowlevel.lib.Http2Header in project webpieces by deanhiller.
the class IntegMultiThreaded method createRequest.
private static List<Http2Header> createRequest(String host, boolean isHttp, String path) {
String scheme;
if (isHttp)
scheme = "http";
else
scheme = "https";
List<Http2Header> headers = new ArrayList<>();
headers.add(new Http2Header(Http2HeaderName.METHOD, "GET"));
headers.add(new Http2Header(Http2HeaderName.AUTHORITY, host));
headers.add(new Http2Header(Http2HeaderName.PATH, path));
headers.add(new Http2Header(Http2HeaderName.SCHEME, scheme));
headers.add(new Http2Header("host", host));
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"));
return headers;
}
use of com.webpieces.http2.api.dto.lowlevel.lib.Http2Header in project webpieces by deanhiller.
the class Responses method createResponse.
public static Http2Response createResponse(int id) {
List<Http2Header> headers = new ArrayList<>();
headers.add(new Http2Header(Http2HeaderName.SERVER, "id"));
headers.add(new Http2Header(Http2HeaderName.STATUS, "200"));
headers.add(new Http2Header(Http2HeaderName.CONTENT_LENGTH, "0"));
Http2Response response = new Http2Response(headers);
response.setEndOfStream(true);
return response;
}
use of com.webpieces.http2.api.dto.lowlevel.lib.Http2Header in project webpieces by deanhiller.
the class Http2Requests method createResponse.
public static Http2Response createResponse(int streamId, boolean eos) {
List<Http2Header> headers = new ArrayList<>();
headers.add(new Http2Header(Http2HeaderName.SERVER, "id"));
headers.add(new Http2Header(Http2HeaderName.STATUS, "200"));
Http2Response response = new Http2Response(headers);
response.setEndOfStream(eos);
response.setStreamId(streamId);
return response;
}
Aggregations