Merge pull request #346 from DataDog/mar-kolya/urlconnection-read-body-keepalive-fix

[HttpUrlConnection] Fix HEAD responses
This commit is contained in:
Tyler Benson 2018-06-08 11:40:50 +10:00 committed by GitHub
commit ec6e4e0278
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 3 deletions

View File

@ -19,7 +19,6 @@ import static ratpack.http.HttpMethod.POST
class HttpUrlConnectionTest extends AgentTestRunner {
static {
System.setProperty("dd.integration.httpurlconnection.enabled", "true")
System.setProperty("http.keepAlive", "false")
}
@Shared
@ -43,8 +42,14 @@ class HttpUrlConnectionTest extends AgentTestRunner {
scope.close()
}
request.body.then {
response.status(200).send(msg)
response.status(200)
// Ratpack seems to be sending body with HEAD requests - RFC specifically forbids this.
// This becomes a major problem with keep-alived requests - client seems to fail to parse
// such response peroperly messing up following requests.
if (request.method.isHead()) {
response.send()
} else {
response.send(msg)
}
}
}