use of com.webpieces.http2.api.dto.highlevel.Http2Response in project webpieces by deanhiller.
the class DefaultCorsProcessor method send403Response.
private void send403Response(ResponseStreamHandle responseStream, Http2Request request) {
Http2Response response = new Http2Response();
response.addHeader(new Http2Header(Http2HeaderName.STATUS, "403"));
response.addHeader(new Http2Header(Http2HeaderName.VARY, "Origin"));
sendResponse(responseStream, response);
}
use of com.webpieces.http2.api.dto.highlevel.Http2Response in project webpieces by deanhiller.
the class InstallSslCertController method modifyResponse.
private Object modifyResponse(Object http2Response) {
Http2Response resp = (Http2Response) http2Response;
Http2Header header = resp.getHeaderLookupStruct().getHeader(Http2HeaderName.CONTENT_TYPE);
header.setValue("text/plain");
return resp;
}
use of com.webpieces.http2.api.dto.highlevel.Http2Response in project webpieces by deanhiller.
the class JsonController method myStream.
// Method signature cannot have RequestContext since in microservices, we implement an api as the server
// AND a client implements the same api AND client does not have a RequestContext!!
@Override
public StreamRef myStream(ResponseStreamHandle handle2) {
RouterStreamHandle handle = (RouterStreamHandle) handle2;
RequestContext requestCtx = Current.getContext();
Http2Response response = handle.createBaseResponse(requestCtx.getRequest().originalRequest, "text/plain", 200, "Ok");
response.setEndOfStream(false);
XFuture<StreamWriter> responseWriter = handle.process(response);
return new RequestStreamEchoWriter(requestCtx, handle, responseWriter);
}
use of com.webpieces.http2.api.dto.highlevel.Http2Response in project webpieces by deanhiller.
the class Requests method createChunkedResponse.
public static Http2Response createChunkedResponse(int id) {
List<Http2Header> headers = new ArrayList<>();
headers.add(new Http2Header(Http2HeaderName.STATUS, "200"));
headers.add(new Http2Header(Http2HeaderName.SERVER, id + ""));
Http2Response response = new Http2Response(headers);
response.setEndOfStream(false);
return response;
}
use of com.webpieces.http2.api.dto.highlevel.Http2Response in project webpieces by deanhiller.
the class TestC5x1StreamStates method testSection5_1ReceiveValidFramesAfterSendRstStreamFrame.
/**
* If this state is reached as a result of sending a RST_STREAM frame, the
* peer that receives the RST_STREAM might have already sent — or enqueued for
* sending — frames on the stream that cannot be withdrawn. An endpoint MUST ignore
* frames that it receives on closed streams after it has sent a RST_STREAM frame. An
* endpoint MAY choose to limit the period over which it ignores frames and
* treat frames that arrive after this time as being in error.
* @throws TimeoutException
* @throws ExecutionException
* @throws InterruptedException
*/
@Test
public void testSection5_1ReceiveValidFramesAfterSendRstStreamFrame() throws InterruptedException, ExecutionException, TimeoutException {
MockResponseListener listener1 = new MockResponseListener();
listener1.setIncomingRespDefault(XFuture.<StreamWriter>completedFuture(null));
Http2Request request1 = Requests.createRequest();
RequestStreamHandle stream = httpSocket.openStream();
StreamRef streamRef = httpSocket.openStream().process(request1, listener1);
XFuture<StreamWriter> future = streamRef.getWriter();
@SuppressWarnings("unused") StreamWriter writer = future.get(2, TimeUnit.SECONDS);
Http2Msg req = mockChannel.getFrameAndClear();
Assert.assertEquals(request1, req);
RstStreamFrame rst = new RstStreamFrame(request1.getStreamId(), Http2ErrorCode.CANCEL);
XFuture<Void> cancel = streamRef.cancel(rst);
cancel.get(2, TimeUnit.SECONDS);
Http2Msg svrRst = mockChannel.getFrameAndClear();
Assert.assertEquals(rst, svrRst);
// simulate server responding before receiving the cancel
Http2Response resp1 = Requests.createEosResponse(request1.getStreamId());
// endOfStream=true
mockChannel.write(resp1);
// Assert.assertEquals(0, mockChannel.getFramesAndClear().size());
// Assert.assertFalse(mockChannel.isClosed());
//
// Assert.assertEquals(0, listener1.getReturnValuesIncomingResponse().size());
}
Aggregations