mirror of
https://github.com/swisspol/GCDWebServer.git
synced 2026-05-31 00:00:10 +08:00
Added video streaming unit test
This commit is contained in:
@@ -1030,8 +1030,13 @@ static void _LogResult(NSString* format, ...) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NSString* expectedContentLength = ARC_BRIDGE_RELEASE(CFHTTPMessageCopyHeaderFieldValue(expectedResponse, CFSTR("Content-Length")));
|
||||||
NSData* expectedBody = ARC_BRIDGE_RELEASE(CFHTTPMessageCopyBody(expectedResponse));
|
NSData* expectedBody = ARC_BRIDGE_RELEASE(CFHTTPMessageCopyBody(expectedResponse));
|
||||||
|
NSString* actualContentLength = ARC_BRIDGE_RELEASE(CFHTTPMessageCopyHeaderFieldValue(actualResponse, CFSTR("Content-Length")));
|
||||||
NSData* actualBody = ARC_BRIDGE_RELEASE(CFHTTPMessageCopyBody(actualResponse));
|
NSData* actualBody = ARC_BRIDGE_RELEASE(CFHTTPMessageCopyBody(actualResponse));
|
||||||
|
if ([actualContentLength isEqualToString:expectedContentLength] && (actualBody.length > expectedBody.length)) { // Handle web browser closing connection before retrieving entire body (e.g. when playing a video file)
|
||||||
|
actualBody = [actualBody subdataWithRange:NSMakeRange(0, expectedBody.length)];
|
||||||
|
}
|
||||||
if (![actualBody isEqualToData:expectedBody]) {
|
if (![actualBody isEqualToData:expectedBody]) {
|
||||||
_LogResult(@" Bodies not matching:\n Expected: %lu bytes\n Actual: %lu bytes", (unsigned long)expectedBody.length, (unsigned long)actualBody.length);
|
_LogResult(@" Bodies not matching:\n Expected: %lu bytes\n Actual: %lu bytes", (unsigned long)expectedBody.length, (unsigned long)actualBody.length);
|
||||||
success = NO;
|
success = NO;
|
||||||
|
|||||||
@@ -23,6 +23,12 @@ function runTests {
|
|||||||
rm -rf "$PAYLOAD_DIR"
|
rm -rf "$PAYLOAD_DIR"
|
||||||
ditto -x -k "$PAYLOAD_ZIP" "$PAYLOAD_DIR"
|
ditto -x -k "$PAYLOAD_ZIP" "$PAYLOAD_DIR"
|
||||||
TZ=GMT find "$PAYLOAD_DIR" -type d -exec SetFile -d "1/1/2014 00:00:00" -m "1/1/2014 00:00:00" '{}' \; # ZIP archives do not preserve directories dates
|
TZ=GMT find "$PAYLOAD_DIR" -type d -exec SetFile -d "1/1/2014 00:00:00" -m "1/1/2014 00:00:00" '{}' \; # ZIP archives do not preserve directories dates
|
||||||
|
if [ "$4" != "" ]; then
|
||||||
|
cp -f "$4" "$PAYLOAD_DIR/Payload"
|
||||||
|
pushd "$PAYLOAD_DIR/Payload"
|
||||||
|
SetFile -d "1/1/2014 00:00:00" -m "1/1/2014 00:00:00" `basename "$4"`
|
||||||
|
popd
|
||||||
|
fi
|
||||||
logLevel=2 $1 -mode "$2" -root "$PAYLOAD_DIR/Payload" -tests "$3"
|
logLevel=2 $1 -mode "$2" -root "$PAYLOAD_DIR/Payload" -tests "$3"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,6 +63,8 @@ runTests $MRC_PRODUCT "webDAV" "Tests/WebDAV-Finder"
|
|||||||
runTests $ARC_PRODUCT "webDAV" "Tests/WebDAV-Finder"
|
runTests $ARC_PRODUCT "webDAV" "Tests/WebDAV-Finder"
|
||||||
runTests $MRC_PRODUCT "webUploader" "Tests/WebUploader"
|
runTests $MRC_PRODUCT "webUploader" "Tests/WebUploader"
|
||||||
runTests $ARC_PRODUCT "webUploader" "Tests/WebUploader"
|
runTests $ARC_PRODUCT "webUploader" "Tests/WebUploader"
|
||||||
|
runTests $MRC_PRODUCT "webServer" "Tests/WebServer-Sample-Movie" "Tests/Sample-Movie.mp4"
|
||||||
|
runTests $ARC_PRODUCT "webServer" "Tests/WebServer-Sample-Movie" "Tests/Sample-Movie.mp4"
|
||||||
|
|
||||||
# Done
|
# Done
|
||||||
echo "\nAll tests completed successfully!"
|
echo "\nAll tests completed successfully!"
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,12 @@
|
|||||||
|
GET /Sample-Movie.mp4 HTTP/1.1
|
||||||
|
Host: localhost:8080
|
||||||
|
Connection: keep-alive
|
||||||
|
Cache-Control: no-cache
|
||||||
|
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
|
||||||
|
Pragma: no-cache
|
||||||
|
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.131 Safari/537.36
|
||||||
|
DNT: 1
|
||||||
|
Referer: http://localhost:8080/
|
||||||
|
Accept-Encoding: gzip,deflate,sdch
|
||||||
|
Accept-Language: en-US,en;q=0.8,fr;q=0.6
|
||||||
|
|
||||||
Binary file not shown.
@@ -0,0 +1,13 @@
|
|||||||
|
GET /Sample-Movie.mp4 HTTP/1.1
|
||||||
|
Host: localhost:8080
|
||||||
|
Connection: keep-alive
|
||||||
|
Cache-Control: no-cache
|
||||||
|
Pragma: no-cache
|
||||||
|
Accept-Encoding: identity;q=1, *;q=0
|
||||||
|
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.131 Safari/537.36
|
||||||
|
Accept: */*
|
||||||
|
DNT: 1
|
||||||
|
Referer: http://localhost:8080/Sample-Movie.mp4
|
||||||
|
Accept-Language: en-US,en;q=0.8,fr;q=0.6
|
||||||
|
Range: bytes=0-
|
||||||
|
|
||||||
Binary file not shown.
@@ -0,0 +1,13 @@
|
|||||||
|
GET /Sample-Movie.mp4 HTTP/1.1
|
||||||
|
Host: localhost:8080
|
||||||
|
Connection: keep-alive
|
||||||
|
Cache-Control: no-cache
|
||||||
|
Pragma: no-cache
|
||||||
|
Accept-Encoding: identity;q=1, *;q=0
|
||||||
|
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.131 Safari/537.36
|
||||||
|
Accept: */*
|
||||||
|
DNT: 1
|
||||||
|
Referer: http://localhost:8080/Sample-Movie.mp4
|
||||||
|
Accept-Language: en-US,en;q=0.8,fr;q=0.6
|
||||||
|
Range: bytes=3391326-
|
||||||
|
|
||||||
Binary file not shown.
@@ -0,0 +1,12 @@
|
|||||||
|
GET /Sample-Movie.mp4 HTTP/1.1
|
||||||
|
Host: localhost:8080
|
||||||
|
Connection: keep-alive
|
||||||
|
Accept-Encoding: identity;q=1, *;q=0
|
||||||
|
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.131 Safari/537.36
|
||||||
|
Accept: */*
|
||||||
|
DNT: 1
|
||||||
|
Referer: http://localhost:8080/Sample-Movie.mp4
|
||||||
|
Accept-Language: en-US,en;q=0.8,fr;q=0.6
|
||||||
|
Range: bytes=168-3391487
|
||||||
|
If-Range: 75279017/1388563200/0
|
||||||
|
|
||||||
Binary file not shown.
@@ -0,0 +1,12 @@
|
|||||||
|
GET /Sample-Movie.mp4 HTTP/1.1
|
||||||
|
Host: localhost:8080
|
||||||
|
Connection: keep-alive
|
||||||
|
Accept-Encoding: identity;q=1, *;q=0
|
||||||
|
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.131 Safari/537.36
|
||||||
|
Accept: */*
|
||||||
|
DNT: 1
|
||||||
|
Referer: http://localhost:8080/Sample-Movie.mp4
|
||||||
|
Accept-Language: en-US,en;q=0.8,fr;q=0.6
|
||||||
|
Range: bytes=168-1023
|
||||||
|
If-Range: 75279017/1388563200/0
|
||||||
|
|
||||||
Reference in New Issue
Block a user