use of com.webpieces.http2.api.dto.highlevel.Http2Response in project webpieces by deanhiller.
the class Http2SynchronousClient method startImpl.
public void startImpl(InetSocketAddress svrAddress) throws UnknownHostException, IOException {
@SuppressWarnings("resource") Socket socket = new Socket(svrAddress.getHostName(), svrAddress.getPort());
OutputStream output = socket.getOutputStream();
Runnable client = new ClientWriter(parser, output);
Thread t1 = new Thread(client);
t1.setName("clientWriter");
t1.start();
InputStream input = socket.getInputStream();
RateRecorder recorder = new RateRecorder(10);
while (true) {
byte[] bytes = new byte[1024];
int read = input.read(bytes);
if (read < 0)
break;
DataWrapper dataWrapper = dataGen.wrapByteArray(bytes, 0, read);
UnmarshalState state = parser.unmarshal(dataWrapper);
List<Http2Msg> messages = state.getParsedFrames();
// simulate going all the way to http2 like the other test does as well
for (Http2Msg p : messages) {
Http2Response resp = (Http2Response) p;
resp.getStreamId();
recorder.increment();
}
}
}
use of com.webpieces.http2.api.dto.highlevel.Http2Response in project webpieces by deanhiller.
the class RequestCreator method createHttp2Response.
public static Http2Response createHttp2Response(int streamId) {
Http2Response resp = new Http2Response();
resp.addHeader(new Http2Header(Http2HeaderName.STATUS, "200"));
resp.addHeader(new Http2Header("serverid", "3"));
resp.setEndOfStream(true);
resp.setStreamId(streamId);
return resp;
}
use of com.webpieces.http2.api.dto.highlevel.Http2Response in project webpieces by deanhiller.
the class EchoStreamingClient method stream.
public StreamRef stream(ResponseStreamHandle handle) {
ProxyStreamHandle h = (ProxyStreamHandle) handle;
Http2Request req = Current.request().originalRequest;
Http2Response response = h.createBaseResponse(req, "application/ndjson", 200, "OK");
try {
StreamWriter writer = h.process(response).get();
return new ProxyStreamRef(new EchoWriter(writer));
} catch (InterruptedException | ExecutionException e) {
throw SneakyThrow.sneak(e);
}
}
use of com.webpieces.http2.api.dto.highlevel.Http2Response in project webpieces by deanhiller.
the class Requests method createResponse.
public static Http2Response createResponse(int streamId) {
List<Http2Header> headers = new ArrayList<>();
headers.add(new Http2Header(Http2HeaderName.STATUS, String.valueOf(StatusCode.HTTP_200_OK.getCode())));
headers.add(new Http2Header(Http2HeaderName.SERVER, "me"));
Http2Response response = new Http2Response(headers);
response.setEndOfStream(false);
response.setStreamId(streamId);
return response;
}
use of com.webpieces.http2.api.dto.highlevel.Http2Response in project webpieces by deanhiller.
the class Requests method createEosResponse.
public static Http2Response createEosResponse(int streamId) {
List<Http2Header> headers = new ArrayList<>();
headers.add(new Http2Header(Http2HeaderName.STATUS, String.valueOf(StatusCode.HTTP_200_OK.getCode())));
headers.add(new Http2Header(Http2HeaderName.SERVER, "me"));
Http2Response response = new Http2Response(headers);
response.setEndOfStream(true);
response.setStreamId(streamId);
return response;
}
Aggregations