File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed
client/src/main/java/io/avaje/http/client Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -393,10 +393,10 @@ public HttpClientResponse TRACE() {
393393 }
394394
395395 private void readResponseContent () {
396- final HttpResponse <byte []> response = asByteArray ();
397- this .httpResponse = response ;
398- context .checkMaybeThrow (response );
396+ final HttpResponse <byte []> response = sendWith (HttpResponse .BodyHandlers .ofByteArray ());
399397 encodedResponseBody = context .readContent (response );
398+ context .afterResponse (this );
399+ context .checkMaybeThrow (response );
400400 }
401401
402402 @ Override
@@ -436,11 +436,19 @@ public <T> Stream<T> stream(Class<T> cls) {
436436
437437 @ Override
438438 public <T > HttpResponse <T > withHandler (HttpResponse .BodyHandler <T > responseHandler ) {
439+ final HttpResponse <T > response = sendWith (responseHandler );
440+ context .afterResponse (this );
441+ return response ;
442+ }
443+
444+ /**
445+ * Prepare and send the request but not performing afterResponse() handling.
446+ */
447+ private <T > HttpResponse <T > sendWith (HttpResponse .BodyHandler <T > responseHandler ) {
439448 context .beforeRequest (this );
440449 addHeaders ();
441450 HttpResponse <T > response = performSend (responseHandler );
442451 httpResponse = response ;
443- context .afterResponse (this );
444452 return response ;
445453 }
446454
You can’t perform that action at this time.
0 commit comments