Skip to content

Commit baee03a

Browse files
committed
Add test (disabled for now) for AsyncHttpClient#1299
1 parent e9364a6 commit baee03a

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
* Copyright (c) 2016 AsyncHttpClient Project. All rights reserved.
3+
*
4+
* This program is licensed to you under the Apache License Version 2.0,
5+
* and you may not use this file except in compliance with the Apache License Version 2.0.
6+
* You may obtain a copy of the Apache License Version 2.0 at
7+
* http://www.apache.org/licenses/LICENSE-2.0.
8+
*
9+
* Unless required by applicable law or agreed to in writing,
10+
* software distributed under the Apache License Version 2.0 is distributed on an
11+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
13+
*/
14+
package org.asynchttpclient;
15+
16+
import static io.netty.handler.codec.http.HttpHeaders.Names.*;
17+
import static io.netty.handler.codec.http.HttpHeaders.Values.*;
18+
import static org.asynchttpclient.Dsl.*;
19+
20+
import java.io.IOException;
21+
22+
import javax.servlet.ServletException;
23+
import javax.servlet.http.HttpServletRequest;
24+
import javax.servlet.http.HttpServletResponse;
25+
26+
import org.eclipse.jetty.server.Request;
27+
import org.eclipse.jetty.server.handler.AbstractHandler;
28+
import org.eclipse.jetty.server.handler.gzip.GzipHandler;
29+
import org.testng.annotations.Test;
30+
31+
public class EofTerminatedTest extends AbstractBasicTest {
32+
33+
private static class StreamHandler extends AbstractHandler {
34+
@Override
35+
public void handle(String pathInContext, Request request, HttpServletRequest httpRequest, HttpServletResponse httpResponse) throws IOException, ServletException {
36+
request.getResponse().getHttpOutput().sendContent(EofTerminatedTest.class.getClassLoader().getResourceAsStream("SimpleTextFile.txt"));
37+
}
38+
}
39+
40+
protected String getTargetUrl() {
41+
return String.format("http://localhost:%d/", port1);
42+
}
43+
44+
@Override
45+
public AbstractHandler configureHandler() throws Exception {
46+
GzipHandler gzipHandler = new GzipHandler();
47+
gzipHandler.setHandler(new StreamHandler());
48+
return gzipHandler;
49+
}
50+
51+
@Test(enabled = false)
52+
public void testEolTerminatedResponse() throws Exception {
53+
try (AsyncHttpClient ahc = asyncHttpClient(config().setMaxRequestRetry(0))) {
54+
ahc.executeRequest(ahc.prepareGet(getTargetUrl()).setHeader(ACCEPT_ENCODING, GZIP_DEFLATE).setHeader(CONNECTION, CLOSE).build()).get();
55+
}
56+
}
57+
}

0 commit comments

Comments
 (0)