From: Stephen D. <sd...@us...> - 2005-06-29 01:56:54
|
Update of /cvsroot/naviserver/naviserver/tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23671/tests Added Files: http_byteranges.test Log Message: Test HTTP byte ranges. --- NEW FILE: http_byteranges.test --- # # The contents of this file are subject to the AOLserver Public License # Version 1.1 (the "License"); you may not use this file except in # compliance with the License. You may obtain a copy of the License at # http://aolserver.com/. # # Software distributed under the License is distributed on an "AS IS" # basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See # the License for the specific language governing rights and limitations # under the License. # # The Original Code is AOLserver Code and related documentation # distributed by AOL. # # The Initial Developer of the Original Code is America Online, # Inc. Portions created by AOL are Copyright (C) 1999 America Online, # Inc. All Rights Reserved. # # Alternatively, the contents of this file may be used under the terms # of the GNU General Public License (the "GPL"), in which case the # provisions of GPL are applicable instead of those above. If you wish # to allow use of your version of this file only under the terms of the # GPL and not to allow others to use your version of this file under the # License, indicate your decision by deleting the provisions above and # replace them with the notice and other provisions required by the GPL. # If you do not delete the provisions above, a recipient may use your # version of this file under either the License or the GPL. # # # $Header: /cvsroot/naviserver/naviserver/tests/http_byteranges.test,v 1.1 2005/06/29 01:56:44 sdeasey Exp $ # # # HTTP 1.1 Byte Ranges: RFC 2616 14.35.1, 14.6, 19.3 # package require tcltest 2.2 namespace import -force ::tcltest::* eval ::tcltest::configure $argv if {[ns_config test listenport]} { testConstraint serverListen true } test http-1.1 {Simple range, beginning} -constraints serverListen -body { nstest_http -getbody 1 -setheaders {Range bytes=0-4} \ -getheaders {Content-length Content-range} \ GET /10bytes } -result {206 5 {bytes 0-4/10} 01234} test http-1.2 {Simple range, end} -constraints serverListen -body { nstest_http -getbody 1 -setheaders {Range bytes=5-9} \ -getheaders {Content-length Content-range} \ GET /10bytes } -result {206 5 {bytes 5-9/10} 56789} test http-1.3 {Relative range} -constraints serverListen -body { nstest_http -getbody 1 -setheaders {Range bytes=5-} \ -getheaders {Content-length Content-range} \ GET /10bytes } -result {206 5 {bytes 5-9/10} 56789} test http-1.4 {Relative range} -constraints serverListen -body { nstest_http -getbody 1 -setheaders {Range bytes=-5} \ -getheaders {Content-length Content-range} \ GET /10bytes } -result {206 5 {bytes 5-9/10} 56789} test http-1.5 {Single byte (1st)} -constraints serverListen -body { nstest_http -getbody 1 -setheaders {Range bytes=0-0} \ -getheaders {Content-length Content-range} \ GET /10bytes } -result {206 1 {bytes 0-0/10} 0} test http-1.6 {Single byte (2nd)} -constraints serverListen -body { nstest_http -getbody 1 -setheaders {Range bytes=1-1} \ -getheaders {Content-length Content-range} \ GET /10bytes } -result {206 1 {bytes 1-1/10} 1} test http-1.6 {Single byte (last)} -constraints serverListen -body { nstest_http -getbody 1 -setheaders {Range bytes=9-9} \ -getheaders {Content-length Content-range} \ GET /10bytes } -result {206 1 {bytes 9-9/10} 9} test http-1.7 {Request more than exists} -constraints serverListen -body { nstest_http -getbody 1 -setheaders {Range bytes=0-10} \ -getheaders {Content-length Content-range} \ GET /10bytes } -result {206 10 {bytes 0-9/10} 0123456789} test http-1.8 {Request more than exists} -constraints serverListen -body { nstest_http -getbody 1 -setheaders {Range bytes=-10} \ -getheaders {Content-length Content-range} \ GET /10bytes } -result {206 10 {bytes 0-9/10} 0123456789} test http-2.1 {Multiple contiguous ranges} -constraints serverListen -body { nstest_http -getbody 1 -setheaders {Range bytes=0-2,3-6} \ -getheaders {Content-length Content-range} \ GET /10bytes } -result {206 6 {bytes 0-6/10} 012345} test http-2.2 {Multiple contiguous ranges} -constraints serverListen -body { nstest_http -getbody 1 -setheaders {Range bytes=0-2,3-5,6-8} \ -getheaders {Content-length Content-range} \ GET /10bytes } -result {206 9 {bytes 0-8/10} 012345678} test http-2.3 {Multiple non-canonical contiguous ranges} -constraints serverListen -body { nstest_http -getbody 1 -setheaders {Range bytes=0-2,3-6} \ -getheaders {Content-length Content-range} \ GET /10bytes } -result {206 6 {bytes 0-6/10} 012345} test http-2.4 {Multiple non-contiguous ranges} -constraints serverListen -body { nstest_http -getbody 1 -setheaders {Range bytes=0-2,7-9} \ -getheaders {Content-type Content-range} \ GET /10bytes } -match regexp -result [list 206 {multipart/byteranges; boundary=[^ ]+} {} \ {[^ ]+\r Content-type: \*/\*\r Content-range: bytes 0-2/10\r 012\r --[^ ]+\r Content-type: \*/\*\r Content-range: bytes 7-9/10\r 789\r --[^ ]+-- }] test http-2.5 {Multiple ranges, out of order} -constraints serverListen -body { nstest_http -getbody 1 -setheaders {Range bytes=7-9,0-2} \ -getheaders {Content-length Content-range} \ GET /10bytes } -match regexp -result [list 206 {multipart/byteranges; boundary=[^ ]+} {} \ {[^ ]+\r Content-type: \*/\*\r Content-range: bytes 7-9/10\r 789\r --[^ ]+\r Content-type: \*/\*\r Content-range: bytes 0-2/10\r 012\r --[^ ]+-- }] test http-3.1 {syntactically invalid} -constraints serverListen -body { nstest_http -getbody 1 -setheaders {Range bytes=3-2} \ -getheaders {Content-length Content-range} \ GET /10bytes } -result {200 10 {} 0123456789} test http-3.2 {syntactically invalid} -constraints serverListen -body { nstest_http -getbody 1 -setheaders {Range bytes=11-10} \ -getheaders {Content-length Content-range} \ GET /10bytes } -result {200 10 {} 0123456789} test http-3.3 {syntactically invalid} -constraints serverListen -body { nstest_http -getbody 1 -setheaders {Range bytes=} \ -getheaders {Content-length Content-range} \ GET /10bytes } -result {200 10 {} 0123456789} test http-3.4 {syntactically invalid} -constraints serverListen -body { nstest_http -getbody 1 -setheaders {Range bytes 0-1} \ -getheaders {Content-length Content-range} \ GET /10bytes } -result {200 10 {} 0123456789} test http-3.5 {syntactically invalid} -constraints serverListen -body { nstest_http -getbody 1 -setheaders {Range 0-1} \ -getheaders {Content-length Content-range} \ GET /10bytes } -result {200 10 {} 0123456789} test http-3.6 {syntactically invalid} -constraints serverListen -body { nstest_http -getbody 1 -setheaders {Range =} \ -getheaders {Content-length Content-range} \ GET /10bytes } -result {200 10 {} 0123456789} test http-3.7 {syntactically invalid} -constraints serverListen -body { nstest_http -getbody 1 -setheaders {Range =-} \ -getheaders {Content-length Content-range} \ GET /10bytes } -result {200 10 {} 0123456789} test http-3.8 {syntactically invalid} -constraints serverListen -body { nstest_http -getbody 1 -setheaders {Range bytes=--6-9} \ -getheaders {Content-length Content-range} \ GET /10bytes } -result {200 10 {} 0123456789} test http-3.9 {syntactically invalid} -constraints serverListen -body { nstest_http -getbody 1 -setheaders {Range bytes=1--6} \ -getheaders {Content-length Content-range} \ GET /10bytes } -result {200 10 {} 0123456789} test http-4.1 {unsatisfiable} -constraints serverListen -body { nstest_http -setheaders {Range bytes=10-10} -getheaders {Content-range} \ GET /10bytes } -result {416 {bytes */10}} test http-4.2 {unsatisfiable} -constraints serverListen -body { nstest_http -setheaders {Range bytes=10-} -getheaders {Content-range} \ GET /10bytes } -result {416 {bytes */10}} cleanupTests |