@Test public void testQueryStringPath() throws Exception { HttpRequestEncoder encoder = new HttpRequestEncoder(); ByteBuf buffer = Unpooled.buffer(64); encoder.encodeInitialLine(buffer, new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/?url=http: String req = buffer.toString(Charset.forName("US-ASCII")); assertEquals("GET /?url=http: }
@Override protected void encodeInitialLine(ByteBuf buf, HttpRequest request) throws Exception { request.getMethod().encode(buf); buf.writeByte(SP); String uri = request.getUri(); if (uri.length() == 0) { uri += SLASH; } else { int start = uri.indexOf(": if (start != -1 && uri.charAt(0) != SLASH) { int startIndex = start + 3; int index = uri.indexOf(QUESTION_MARK, startIndex); if (index == -1) { if (uri.lastIndexOf(SLASH) <= startIndex) { uri += SLASH; } } else { if (uri.lastIndexOf(SLASH, index) <= startIndex) { int len = uri.length(); StringBuilder sb = new StringBuilder(len + 1); sb.append(uri, 0, index) .append(SLASH) .append(uri, index, len); uri = sb.toString(); } } } } buf.writeBytes(uri.getBytes(CharsetUtil.UTF_8)); buf.writeByte(SP); request.getProtocolVersion().encode(buf); buf.writeBytes(CRLF); }
HttpRequestEncoder extends HttpObjectEncoder<HttpRequest> { @Override protected void encodeInitialLine(ByteBuf buf, HttpRequest request) throws Exception { request.getMethod().encode(buf); buf.writeByte(SP); String uri = request.getUri(); if (uri.length() == 0) { uri += SLASH; } else { int start = uri.indexOf(": if (start != -1 && uri.charAt(0) != SLASH) { int startIndex = start + 3; int index = uri.indexOf(QUESTION_MARK, startIndex); if (index == -1) { if (uri.lastIndexOf(SLASH) <= startIndex) { uri += SLASH; } } else { if (uri.lastIndexOf(SLASH, index) <= startIndex) { int len = uri.length(); StringBuilder sb = new StringBuilder(len + 1); sb.append(uri, 0, index) .append(SLASH) .append(uri, index, len); uri = sb.toString(); } } } } buf.writeBytes(uri.getBytes(CharsetUtil.UTF_8)); buf.writeByte(SP); request.getProtocolVersion().encode(buf); buf.writeBytes(CRLF); } }
HttpRequestEncoder extends HttpObjectEncoder<HttpRequest> { @Override protected void encodeInitialLine(ByteBuf buf, HttpRequest request) throws Exception { request.getMethod().encode(buf); buf.writeByte(SP); String uri = request.getUri(); if (uri.length() == 0) { uri += SLASH; } else { int start = uri.indexOf(": if (start != -1 && uri.charAt(0) != SLASH) { int startIndex = start + 3; int index = uri.indexOf(QUESTION_MARK, startIndex); if (index == -1) { if (uri.lastIndexOf(SLASH) <= startIndex) { uri += SLASH; } } else { if (uri.lastIndexOf(SLASH, index) <= startIndex) { int len = uri.length(); StringBuilder sb = new StringBuilder(len + 1); sb.append(uri, 0, index) .append(SLASH) .append(uri, index, len); uri = sb.toString(); } } } } buf.writeBytes(uri.getBytes(CharsetUtil.UTF_8)); buf.writeByte(SP); request.getProtocolVersion().encode(buf); buf.writeBytes(CRLF); }  }
HttpRequestEncoder extends HttpObjectEncoder<HttpRequest> { @Override protected void encodeInitialLine(ByteBuf buf, HttpRequest request) throws Exception { request.getMethod().encode(buf); buf.writeByte(SP); String uri = request.getUri(); if (uri.length() == 0) { uri += SLASH; } else { int start = uri.indexOf(": if (start != -1 && uri.charAt(0) != SLASH) { int startIndex = start + 3; int index = uri.indexOf(QUESTION_MARK, startIndex); if (index == -1) { if (uri.lastIndexOf(SLASH) <= startIndex) { uri += SLASH; } } else { if (uri.lastIndexOf(SLASH, index) <= startIndex) { int len = uri.length(); StringBuilder sb = new StringBuilder(len + 1); sb.append(uri, 0, index) .append(SLASH) .append(uri, index, len); uri = sb.toString(); } } } } buf.writeBytes(uri.getBytes(CharsetUtil.UTF_8)); buf.writeByte(SP); request.getProtocolVersion().encode(buf); buf.writeBytes(CRLF); }  @Override boolean acceptOutboundMessage(Object msg); }
HttpRequestEncoder extends HttpObjectEncoder<HttpRequest> { @Override protected void encodeInitialLine(ByteBuf buf, HttpRequest request) throws Exception { request.getMethod().encode(buf); buf.writeByte(SP); String uri = request.getUri(); if (uri.length() == 0) { uri += SLASH; } else { int start = uri.indexOf(": if (start != -1 && uri.charAt(0) != SLASH) { int startIndex = start + 3; int index = uri.indexOf(QUESTION_MARK, startIndex); if (index == -1) { if (uri.lastIndexOf(SLASH) <= startIndex) { uri += SLASH; } } else { if (uri.lastIndexOf(SLASH, index) <= startIndex) { int len = uri.length(); StringBuilder sb = new StringBuilder(len + 1); sb.append(uri, 0, index) .append(SLASH) .append(uri, index, len); uri = sb.toString(); } } } } buf.writeBytes(uri.getBytes(CharsetUtil.UTF_8)); buf.writeByte(SP); request.getProtocolVersion().encode(buf); buf.writeBytes(CRLF); }  @Override boolean acceptOutboundMessage(Object msg);  }