|
13 | 13 | packageorg.asynchttpclient; |
14 | 14 |
|
15 | 15 | importstaticio.netty.handler.codec.http.HttpHeaderNames.CONTENT_LENGTH; |
16 | | -importstaticjava.nio.charset.StandardCharsets.UTF_8; |
17 | 16 | importstaticorg.asynchttpclient.Dsl.*; |
18 | 17 | importstaticorg.asynchttpclient.test.TestUtils.*; |
19 | 18 |
|
@@ -72,17 +71,15 @@ private class IncompleteResponseHandler extends AbstractHandler { |
72 | 71 |
|
73 | 72 | publicvoidhandle(Strings,Requestr,HttpServletRequestrequest,HttpServletResponseresponse)throwsIOException,ServletException { |
74 | 73 | // NOTE: handler sends less bytes than are given in Content-Length, which should lead to timeout |
75 | | - |
| 74 | +response.setStatus(200); |
76 | 75 | OutputStreamout =response.getOutputStream(); |
77 | | -if (request.getHeader("X-Content") !=null) { |
78 | | -Stringcontent =request.getHeader("X-Content"); |
79 | | -response.setHeader(CONTENT_LENGTH.toString(),String.valueOf(content.getBytes(UTF_8).length)); |
80 | | -out.write(content.substring(1).getBytes(UTF_8)); |
81 | | - }else { |
82 | | -response.setStatus(200); |
83 | | - } |
| 76 | +response.setIntHeader(CONTENT_LENGTH.toString(),1000); |
| 77 | +out.write(0); |
84 | 78 | out.flush(); |
85 | | -out.close(); |
| 79 | +try { |
| 80 | +Thread.sleep(LONG_FUTURE_TIMEOUT +100); |
| 81 | + }catch (InterruptedExceptione) { |
| 82 | + } |
86 | 83 | } |
87 | 84 | } |
88 | 85 |
|
@@ -172,7 +169,7 @@ protected Future<Response> execute(AsyncHttpClient client, boolean basic, boolea |
172 | 169 | } |
173 | 170 | } |
174 | 171 |
|
175 | | -returnclient.prepareGet(url).setRealm(realm.setUsePreemptiveAuth(preemptive).build()).setHeader("X-Content","Test").execute(); |
| 172 | +returnclient.prepareGet(url).setRealm(realm.setUsePreemptiveAuth(preemptive).build()).execute(); |
176 | 173 | } |
177 | 174 |
|
178 | 175 | @Override |
|