@@ -78,6 +78,7 @@ public RequestConfig.Builder setRequestConfig() {
7878
7979 public void resetHttpClient () {
8080 try {
81+ this .httpCookieStore .clear ();
8182 this .httpClient = newHttpClient ();
8283 } catch (NoSuchAlgorithmException | KeyStoreException | KeyManagementException e ) {
8384 throw new RuntimeException (e );
@@ -124,7 +125,7 @@ public RequestResponse sendGet(String url) throws IOException, HttpClientExcepti
124125 httpGet .setConfig (getRequestConfig ().build ());
125126 httpGet .addHeader (HttpHeaders .ACCEPT , "application/json, text/plain, */*" );
126127 HttpResponse httpResponse = getHttpClient ().execute (httpGet );
127- assertRequest (httpResponse );
128+ assertRequest (httpResponse , start );
128129 return (new RequestResponse (httpResponse , start ));
129130 }
130131
@@ -136,7 +137,7 @@ public RequestResponse sendPost(String url, String content, ContentType contentT
136137 httpPost .addHeader (HttpHeaders .ACCEPT , "application/json, text/plain, */*" );
137138 httpPost .setEntity (new StringEntity (content ));
138139 HttpResponse httpResponse = getHttpClient ().execute (httpPost );
139- assertRequest (httpResponse );
140+ assertRequest (httpResponse , start );
140141 return (new RequestResponse (httpResponse , start ));
141142 }
142143
@@ -148,7 +149,7 @@ public RequestResponse sendForm(String url, List<NameValuePair> form) throws IOE
148149 UrlEncodedFormEntity entity = new UrlEncodedFormEntity (form , Consts .UTF_8 );
149150 httpPost .setEntity (entity );
150151 HttpResponse httpResponse = httpClient .execute (httpPost );
151- assertRequest (httpResponse );
152+ assertRequest (httpResponse , start );
152153 return (new RequestResponse (httpResponse , start ));
153154 }
154155
@@ -158,7 +159,7 @@ public RequestResponse sendDelete(String url) throws IOException, HttpClientExce
158159 httpDelete .setConfig (getRequestConfig ().build ());
159160 httpDelete .addHeader (HttpHeaders .ACCEPT , "application/json, text/plain, */*" );
160161 HttpResponse httpResponse = httpClient .execute (httpDelete );
161- assertRequest (httpResponse );
162+ assertRequest (httpResponse , start );
162163 return (new RequestResponse (httpResponse , start ));
163164 }
164165
@@ -170,16 +171,16 @@ public RequestResponse sendPut(String url, String content, ContentType contentTy
170171 httpPut .addHeader (HttpHeaders .ACCEPT , "application/json, text/plain, */*" );
171172 httpPut .setEntity (new StringEntity (content ));
172173 HttpResponse httpResponse = getHttpClient ().execute (httpPut );
173- assertRequest (httpResponse );
174+ assertRequest (httpResponse , start );
174175 return (new RequestResponse (httpResponse , start ));
175176 }
176177
177- private void assertRequest (HttpResponse httpResponse ) throws HttpClientException , HttpServerException {
178+ private void assertRequest (HttpResponse httpResponse , Date startDate ) throws HttpClientException , HttpServerException , IOException {
178179 int statusCode = httpResponse .getStatusLine ().getStatusCode ();
179180 if (statusCode >= 500 && statusCode <= 599 )
180- throw new HttpServerException (httpResponse );
181+ throw new HttpServerException (new RequestResponse ( httpResponse , startDate ) );
181182 else if (statusCode >= 400 && statusCode <= 499 )
182- throw new HttpClientException (httpResponse );
183+ throw new HttpClientException (new RequestResponse ( httpResponse , startDate ) );
183184 }
184185
185186 /*
0 commit comments