use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.FullHttpRequest in project netty by netty.
the class WebSocketClientHandshakerTest method testRawPathWithQuery.
@Test
public void testRawPathWithQuery() {
URI uri = URI.create("ws://localhost:9999/path%20with%20ws?a=b%20c");
WebSocketClientHandshaker handshaker = newHandshaker(uri);
FullHttpRequest request = handshaker.newHandshakeRequest();
try {
assertEquals("/path%20with%20ws?a=b%20c", request.uri());
} finally {
request.release();
}
}
use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.FullHttpRequest in project netty by netty.
the class WebSocketClientHandshaker07Test method testSecOriginWss.
@Test
public void testSecOriginWss() {
URI uri = URI.create("wss://localhost/path%20with%20ws");
WebSocketClientHandshaker handshaker = newHandshaker(uri);
FullHttpRequest request = handshaker.newHandshakeRequest();
try {
assertEquals("https://localhost", request.headers().get(HttpHeaderNames.SEC_WEBSOCKET_ORIGIN));
} finally {
request.release();
}
}
use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.FullHttpRequest in project netty by netty.
the class WebSocketClientHandshakerTest method testRawPath.
@Test
public void testRawPath() {
URI uri = URI.create("ws://localhost:9999/path%20with%20ws");
WebSocketClientHandshaker handshaker = newHandshaker(uri);
FullHttpRequest request = handshaker.newHandshakeRequest();
try {
assertEquals("/path%20with%20ws", request.getUri());
} finally {
request.release();
}
}
use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.FullHttpRequest in project asterixdb by apache.
the class ConnectorApiServletTest method testGet.
@Test
public void testGet() throws Exception {
// Starts test asterixdb cluster.
SqlppExecutionTest.setUp();
// Configures a test connector api servlet.
ConnectorApiServlet let = new ConnectorApiServlet(new ConcurrentHashMap<>(), new String[] { "/" }, (ICcApplicationContext) ExecutionTestUtil.integrationUtil.cc.getApplicationContext());
Map<String, NodeControllerInfo> nodeMap = new HashMap<>();
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
PrintWriter outputWriter = new PrintWriter(outputStream);
// Creates mocks.
IHyracksClientConnection mockHcc = mock(IHyracksClientConnection.class);
NodeControllerInfo mockInfo1 = mock(NodeControllerInfo.class);
NodeControllerInfo mockInfo2 = mock(NodeControllerInfo.class);
IServletRequest mockRequest = mock(IServletRequest.class);
IServletResponse mockResponse = mock(IServletResponse.class);
FullHttpRequest mockHttpRequest = mock(FullHttpRequest.class);
// Put stuff in let map
let.ctx().put(ServletConstants.HYRACKS_CONNECTION_ATTR, mockHcc);
// Sets up mock returns.
when(mockRequest.getHttpRequest()).thenReturn(mockHttpRequest);
when(mockHttpRequest.method()).thenReturn(HttpMethod.GET);
when(mockRequest.getParameter("dataverseName")).thenReturn("Metadata");
when(mockRequest.getParameter("datasetName")).thenReturn("Dataset");
when(mockResponse.writer()).thenReturn(outputWriter);
when(mockHcc.getNodeControllerInfos()).thenReturn(nodeMap);
when(mockInfo1.getNetworkAddress()).thenReturn(new NetworkAddress("127.0.0.1", 3099));
when(mockInfo2.getNetworkAddress()).thenReturn(new NetworkAddress("127.0.0.2", 3099));
// Calls ConnectorAPIServlet.formResponseObject.
nodeMap.put("asterix_nc1", mockInfo1);
nodeMap.put("asterix_nc2", mockInfo2);
let.handle(mockRequest, mockResponse);
// Constructs the actual response.
ObjectMapper om = new ObjectMapper();
ObjectNode actualResponse = (ObjectNode) om.readTree(outputStream.toString());
// Checks the temp-or-not, primary key, data type of the dataset.
boolean temp = actualResponse.get("temp").asBoolean();
Assert.assertFalse(temp);
String primaryKey = actualResponse.get("keys").asText();
Assert.assertEquals("DataverseName,DatasetName", primaryKey);
ARecordType recordType = (ARecordType) JSONDeserializerForTypes.convertFromJSON(actualResponse.get("type"));
Assert.assertEquals(getMetadataRecordType("Metadata", "Dataset"), recordType);
// Checks the correctness of results.
ArrayNode splits = (ArrayNode) actualResponse.get("splits");
String path = (splits.get(0)).get("path").asText();
Assert.assertTrue(path.endsWith("Metadata/Dataset_idx_Dataset"));
// Tears down the asterixdb cluster.
SqlppExecutionTest.tearDown();
}
use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.FullHttpRequest in project netty by netty.
the class Http2ServerDowngrader method decode.
@Override
protected void decode(ChannelHandlerContext ctx, Http2StreamFrame frame, List<Object> out) throws Exception {
if (frame instanceof Http2HeadersFrame) {
// not really the id
int id = 0;
Http2HeadersFrame headersFrame = (Http2HeadersFrame) frame;
Http2Headers headers = headersFrame.headers();
if (headersFrame.isEndStream()) {
if (headers.method() == null) {
LastHttpContent last = new DefaultLastHttpContent(Unpooled.EMPTY_BUFFER, validateHeaders);
HttpConversionUtil.addHttp2ToHttpHeaders(id, headers, last.trailingHeaders(), HttpVersion.HTTP_1_1, true, true);
out.add(last);
} else {
FullHttpRequest full = HttpConversionUtil.toFullHttpRequest(id, headers, ctx.alloc(), validateHeaders);
out.add(full);
}
} else {
HttpRequest req = HttpConversionUtil.toHttpRequest(id, headersFrame.headers(), validateHeaders);
if (!HttpUtil.isContentLengthSet(req)) {
req.headers().add(HttpHeaderNames.TRANSFER_ENCODING, HttpHeaderValues.CHUNKED);
}
out.add(req);
}
} else if (frame instanceof Http2DataFrame) {
Http2DataFrame dataFrame = (Http2DataFrame) frame;
if (dataFrame.isEndStream()) {
out.add(new DefaultLastHttpContent(dataFrame.content(), validateHeaders));
} else {
out.add(new DefaultHttpContent(dataFrame.content()));
}
}
ReferenceCountUtil.retain(frame);
}
Aggregations