Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,13 @@ public void process(final HttpResponse response, final EntityDetails entity, fin
throws HttpException, IOException {
Args.notNull(response, "HTTP response");
final int status = response.getCode();
switch (status) {
case HttpStatus.SC_NO_CONTENT:
case HttpStatus.SC_NOT_MODIFIED:
if (entity != null) {
throw new ProtocolException("Response " + status + " must not enclose an entity");
}
if (status >= 100 && status < 200
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arturobernalg This is unnecessary. 1xx responses never get processed by the protocol interceptors. Their life-cycle is completely separate.

|| status == HttpStatus.SC_NO_CONTENT
|| status == HttpStatus.SC_RESET_CONTENT
|| status == HttpStatus.SC_NOT_MODIFIED) {
if (entity != null) {
throw new ProtocolException("Response " + status + " must not enclose an entity");
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1159,5 +1159,28 @@ void testInvalidDateReplaced() throws Exception {
Assertions.assertNotEquals("Invalid Date", newDateHeader.getValue());
}

@Test
void testResponseConformanceInformationalWithEntity() {
final HttpCoreContext context = HttpCoreContext.create();
final ClassicHttpResponse response = new BasicClassicHttpResponse(HttpStatus.SC_CONTINUE, "Continue");
response.setEntity(new StringEntity("stuff", StandardCharsets.US_ASCII));

final ResponseConformance interceptor = new ResponseConformance();
Assertions.assertThrows(ProtocolException.class, () ->
interceptor.process(response, response.getEntity(), context));
}

@Test
void testResponseConformanceResetContentWithEntity() {
final HttpCoreContext context = HttpCoreContext.create();
final ClassicHttpResponse response = new BasicClassicHttpResponse(HttpStatus.SC_RESET_CONTENT, "Reset Content");
response.setEntity(new StringEntity("stuff", StandardCharsets.US_ASCII));

final ResponseConformance interceptor = new ResponseConformance();
Assertions.assertThrows(ProtocolException.class, () ->
interceptor.process(response, response.getEntity(), context));
}



}
Loading