Skip to content
Open
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 @@ -271,7 +271,6 @@ trait CommonTests {
@Test
void 'trace without event'() {
def respContentType = null
def respContentLength = null
def trace = container.traceFromRequest('/hello.php') { HttpResponse<InputStream> resp ->
assert resp.statusCode() == 200
def headerContentType = resp.headers().firstValue('Content-Type')
Expand All @@ -288,6 +287,28 @@ trait CommonTests {
assert span.meta."http.response.headers.content-language" == 'en'
}

@Test
void 'response with zero content-length'() {
def trace = container.traceFromRequest('/zero_content_length.php') { HttpResponse<InputStream> resp ->
assert resp.statusCode() == 200
}

def spanContentLength = trace.first().meta."http.response.headers.content-length"
assert spanContentLength instanceof String
assert spanContentLength == '0'
}

@Test
void 'response with non-zero content-length'() {
def trace = container.traceFromRequest('/non_zero_content_length.php') { HttpResponse<InputStream> resp ->
assert resp.statusCode() == 200
}

def spanContentLength = trace.first().meta."http.response.headers.content-length"
assert spanContentLength instanceof String
assert spanContentLength == '12'
}

@Test
void 'trace with an attack'() {
HttpRequest req = container.buildReq('/hello.php')
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php
$content = 'Hello world!';
header('Content-Length: ' . strlen($content));
header('Content-Type: text/plain');
echo $content;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php
header('Content-Length: 0');
header('Content-Type: text/plain');
Loading