You can subscribe to this list here.
2005 |
Jan
|
Feb
(32) |
Mar
(56) |
Apr
(92) |
May
(39) |
Jun
(226) |
Jul
(98) |
Aug
(66) |
Sep
|
Oct
(153) |
Nov
(43) |
Dec
(42) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(97) |
Feb
(141) |
Mar
(147) |
Apr
(80) |
May
(51) |
Jun
(93) |
Jul
(88) |
Aug
(50) |
Sep
(179) |
Oct
(48) |
Nov
(82) |
Dec
(71) |
2007 |
Jan
(42) |
Feb
(46) |
Mar
(123) |
Apr
(21) |
May
(139) |
Jun
(59) |
Jul
(34) |
Aug
(57) |
Sep
(47) |
Oct
(137) |
Nov
(49) |
Dec
(12) |
2008 |
Jan
(10) |
Feb
(8) |
Mar
(63) |
Apr
(17) |
May
(34) |
Jun
(38) |
Jul
(16) |
Aug
(62) |
Sep
(9) |
Oct
(121) |
Nov
(38) |
Dec
(4) |
2009 |
Jan
|
Feb
(11) |
Mar
(9) |
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2010 |
Jan
|
Feb
|
Mar
(4) |
Apr
(10) |
May
(1) |
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2011 |
Jan
(1) |
Feb
(1) |
Mar
(3) |
Apr
(2) |
May
|
Jun
|
Jul
|
Aug
(3) |
Sep
(2) |
Oct
(1) |
Nov
|
Dec
(12) |
2012 |
Jan
(26) |
Feb
(1) |
Mar
(15) |
Apr
(1) |
May
(1) |
Jun
(7) |
Jul
(2) |
Aug
|
Sep
(1) |
Oct
(52) |
Nov
(8) |
Dec
(25) |
2013 |
Jan
(35) |
Feb
(14) |
Mar
(10) |
Apr
(10) |
May
(29) |
Jun
(16) |
Jul
(5) |
Aug
(8) |
Sep
(8) |
Oct
(6) |
Nov
(1) |
Dec
(3) |
2014 |
Jan
(16) |
Feb
(13) |
Mar
(5) |
Apr
(9) |
May
(21) |
Jun
(6) |
Jul
(5) |
Aug
(2) |
Sep
(59) |
Oct
(115) |
Nov
(122) |
Dec
(45) |
2015 |
Jan
(31) |
Feb
(32) |
Mar
(19) |
Apr
(25) |
May
(3) |
Jun
(4) |
Jul
(18) |
Aug
(3) |
Sep
(23) |
Oct
(11) |
Nov
(17) |
Dec
(12) |
2016 |
Jan
(20) |
Feb
(27) |
Mar
(20) |
Apr
(40) |
May
(35) |
Jun
(48) |
Jul
(44) |
Aug
(51) |
Sep
(18) |
Oct
(42) |
Nov
(39) |
Dec
(29) |
2017 |
Jan
(37) |
Feb
(34) |
Mar
(20) |
Apr
(37) |
May
(10) |
Jun
(2) |
Jul
(14) |
Aug
(15) |
Sep
(25) |
Oct
(29) |
Nov
(15) |
Dec
(29) |
2018 |
Jan
(5) |
Feb
(15) |
Mar
(6) |
Apr
(20) |
May
(39) |
Jun
(39) |
Jul
(17) |
Aug
(20) |
Sep
(10) |
Oct
(17) |
Nov
(20) |
Dec
(8) |
2019 |
Jan
(28) |
Feb
(21) |
Mar
(13) |
Apr
(44) |
May
(44) |
Jun
(28) |
Jul
(51) |
Aug
(30) |
Sep
(7) |
Oct
(20) |
Nov
(8) |
Dec
(21) |
2020 |
Jan
(27) |
Feb
(5) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Stephen D. <sd...@us...> - 2005-04-18 12:57:24
|
Update of /cvsroot/naviserver/naviserver/nsd In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27805/nsd Modified Files: conn.c Log Message: Prevent truncation of content already in dstring when location is appended. Use nstest_http in tests. Index: conn.c =================================================================== RCS file: /cvsroot/naviserver/naviserver/nsd/conn.c,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** conn.c 17 Apr 2005 08:10:05 -0000 1.10 --- conn.c 18 Apr 2005 12:57:15 -0000 1.11 *************** *** 481,488 **** Ns_ConnLocationAppend(Ns_Conn *conn, Ns_DString *dest) { ! Conn *connPtr = (Conn *) conn; ! NsServer *servPtr = connPtr->servPtr; ! Ns_Set *headers; ! char *location, *host, *p; if (servPtr->vhost.connLocationProc != NULL) { --- 481,489 ---- Ns_ConnLocationAppend(Ns_Conn *conn, Ns_DString *dest) { ! Conn *connPtr = (Conn *) conn; ! NsServer *servPtr = connPtr->servPtr; ! Ns_Set *headers; ! Ns_DString ds; ! char *location, *host, *p; if (servPtr->vhost.connLocationProc != NULL) { *************** *** 531,542 **** } ! Ns_DStringAppend(dest, connPtr->location); ! location = strstr(dest->string, "://"); if (location != NULL) { ! Ns_DStringTrunc(dest, (location - dest->string) + 3); } else { /* server missconfiguration, should begin: SCHEME:// */ Ns_DStringAppend(dest, "http://"); } location = Ns_DStringAppend(dest, host); --- 532,550 ---- } ! /* ! * Get the scheme from the driver location, default to http://. ! */ ! ! Ns_DStringInit(&ds); ! Ns_DStringAppend(&ds, connPtr->location); ! location = strstr(ds.string, "://"); if (location != NULL) { ! Ns_DStringTrunc(&ds, (location - ds.string) + 3); ! Ns_DStringNAppend(dest, ds.string, ds.length); } else { /* server missconfiguration, should begin: SCHEME:// */ Ns_DStringAppend(dest, "http://"); } + Ns_DStringFree(&ds); location = Ns_DStringAppend(dest, host); *************** *** 837,863 **** *---------------------------------------------------------------------- * - * NsIsIdConn -- - * - * Given an conn ID, could this be a conn ID? - * - * Results: - * Boolean - * - * Side effects: - * None - * - *---------------------------------------------------------------------- - */ - - int - NsIsIdConn(char *connId) - { - return (connId && *connId == 'c') ? NS_TRUE : NS_FALSE; - } - - - /* - *---------------------------------------------------------------------- - * * Ns_ConnGetWriteEncodedFlag -- * --- 845,848 ---- *************** *** 994,998 **** case CUrlvIdx: ! if (objc == 2 || (objc == 3 && NsIsIdConn(Tcl_GetString(objv[2])))) { for (idx = 0; idx < request->urlc; idx++) { Tcl_AppendElement(interp, request->urlv[idx]); --- 979,983 ---- case CUrlvIdx: ! if (objc == 2) { for (idx = 0; idx < request->urlc; idx++) { Tcl_AppendElement(interp, request->urlv[idx]); |
From: Stephen D. <sd...@us...> - 2005-04-18 12:57:23
|
Update of /cvsroot/naviserver/naviserver/tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27805/tests Modified Files: ns_conn_host.test Log Message: Prevent truncation of content already in dstring when location is appended. Use nstest_http in tests. Index: ns_conn_host.test =================================================================== RCS file: /cvsroot/naviserver/naviserver/tests/ns_conn_host.test,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ns_conn_host.test 12 Apr 2005 06:21:24 -0000 1.1 --- ns_conn_host.test 18 Apr 2005 12:57:15 -0000 1.2 *************** *** 22,49 **** test ns_conn_location-1.1 {http 1.1 host} -constraints serverListen -setup { ! ns_eval {{ ! proc conn_location_request {args} { ! ns_return 200 text/plain [ns_conn location] ! } ! }} ! ns_register_proc GET /location conn_location_request } -body { ! set id [ns_http queue GET $self/location] ! ns_http wait $id location ! set location } -cleanup { - ns_eval {{ - rename conn_location_request {} - }} ns_unregister_proc GET /location ! ns_http cleanup ! unset -nocomplain id location ! } -result $self ! ! ! ! unset -nocomplain driverhost self cleanupTests --- 22,34 ---- test ns_conn_location-1.1 {http 1.1 host} -constraints serverListen -setup { ! ns_register_proc GET /location {ns_return 200 text/plain [ns_conn location] ;#} } -body { ! nstest_http -getbody 1 GET $self/location } -cleanup { ns_unregister_proc GET /location ! } -result [list 200 $self] + unset -nocomplain driverlocation self cleanupTests |
From: Stephen D. <sd...@us...> - 2005-04-18 12:57:23
|
Update of /cvsroot/naviserver/naviserver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27805 Modified Files: ChangeLog Log Message: Prevent truncation of content already in dstring when location is appended. Use nstest_http in tests. Index: ChangeLog =================================================================== RCS file: /cvsroot/naviserver/naviserver/ChangeLog,v retrieving revision 1.50 retrieving revision 1.51 diff -C2 -d -r1.50 -r1.51 *** ChangeLog 18 Apr 2005 12:52:35 -0000 1.50 --- ChangeLog 18 Apr 2005 12:57:15 -0000 1.51 *************** *** 1,4 **** --- 1,8 ---- 2005-04-18 Stephen Deasey <sd...@us...> + * nsd/conn.c: + * tests/ns_conn_host.test: Prevent truncation of content already in + dstring when location is appended. Use nstest_http in tests. + * nsd/nsconf.c: * tests/test.nscfg: |
From: Stephen D. <sd...@us...> - 2005-04-18 12:52:51
|
Update of /cvsroot/naviserver/naviserver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25140 Modified Files: ChangeLog Log Message: Add helper command nstest_http for test suite and new config parameter ns/parameters/tcllibrary so that the tcl shared library can be set to an arbitrary path. Index: ChangeLog =================================================================== RCS file: /cvsroot/naviserver/naviserver/ChangeLog,v retrieving revision 1.49 retrieving revision 1.50 diff -C2 -d -r1.49 -r1.50 *** ChangeLog 17 Apr 2005 18:38:49 -0000 1.49 --- ChangeLog 18 Apr 2005 12:52:35 -0000 1.50 *************** *** 1,2 **** --- 1,11 ---- + 2005-04-18 Stephen Deasey <sd...@us...> + + * nsd/nsconf.c: + * tests/test.nscfg: + * tests/testserver/modules/http.tcl: Add helper command + nstest_http for test suite and new config parameter + ns/parameters/tcllibrary so that the tcl shared library can be set + to an arbitrary path. + 2005-04-17 Zoran Vasiljevic <vas...@us...> |
From: Stephen D. <sd...@us...> - 2005-04-18 12:52:50
|
Update of /cvsroot/naviserver/naviserver/tests/testserver/modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25140/tests/testserver/modules Added Files: http.tcl Log Message: Add helper command nstest_http for test suite and new config parameter ns/parameters/tcllibrary so that the tcl shared library can be set to an arbitrary path. --- NEW FILE: http.tcl --- # # 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. # # Copyright (C) 2005 Stephen Deasey <sd...@us...> # # 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/testserver/modules/http.tcl,v 1.1 2005/04/18 12:52:35 sdeasey Exp $ # # # Fetch a page from the server, setting any special headers and returning # the requested parts of the response. # proc nstest_http {args} { ns_parseargs {-setheaders -getheaders {-getbody 0} -- method location {body ""}} $args set reqhdrs [ns_set create] if {[info exists setheaders]} { foreach {k v} $setheaders { ns_set put $reqhdrs $k $v } } set httpid [ns_http queue $method $location $body $reqhdrs] set resphdrs [ns_set create] ns_http wait $httpid result 10 $resphdrs set response [lindex [split [ns_set name $resphdrs]] 1] if {[info exists getheaders]} { foreach h $getheaders { lappend response [ns_set iget $resphdrs $h] } } if {[string is true $getbody]} { lappend response $result } ns_http cleanup return $response } |
From: Stephen D. <sd...@us...> - 2005-04-18 12:52:47
|
Update of /cvsroot/naviserver/naviserver/nsd In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25140/nsd Modified Files: nsconf.c Log Message: Add helper command nstest_http for test suite and new config parameter ns/parameters/tcllibrary so that the tcl shared library can be set to an arbitrary path. Index: nsconf.c =================================================================== RCS file: /cvsroot/naviserver/naviserver/nsd/nsconf.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** nsconf.c 16 Feb 2005 08:39:53 -0000 1.1.1.1 --- nsconf.c 18 Apr 2005 12:52:35 -0000 1.2 *************** *** 245,251 **** * tclinit.c */ ! ! Ns_HomePath(&ds, "modules", "tcl", NULL); ! nsconf.tcl.sharedlibrary = Ns_DStringExport(&ds); nsconf.tcl.lockoninit = GetBool("tclinitlock", TCL_INITLCK_BOOL); --- 245,254 ---- * tclinit.c */ ! ! nsconf.tcl.sharedlibrary = Ns_ConfigGetValue(NS_CONFIG_PARAMETERS, "tcllibrary"); ! if (nsconf.tcl.sharedlibrary == NULL) { ! Ns_HomePath(&ds, "modules", "tcl", NULL); ! nsconf.tcl.sharedlibrary = Ns_DStringExport(&ds); ! } nsconf.tcl.lockoninit = GetBool("tclinitlock", TCL_INITLCK_BOOL); |
From: Stephen D. <sd...@us...> - 2005-04-18 12:52:47
|
Update of /cvsroot/naviserver/naviserver/tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25140/tests Modified Files: test.nscfg Log Message: Add helper command nstest_http for test suite and new config parameter ns/parameters/tcllibrary so that the tcl shared library can be set to an arbitrary path. Index: test.nscfg =================================================================== RCS file: /cvsroot/naviserver/naviserver/tests/test.nscfg,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** test.nscfg 12 Apr 2005 06:21:24 -0000 1.2 --- test.nscfg 18 Apr 2005 12:52:35 -0000 1.3 *************** *** 34,37 **** --- 34,38 ---- ns_section "ns/parameters" ns_param home [ns_config "test" home] + ns_param tcllibrary [ns_config "test" home]/../tcl ns_section "ns/servers" *************** *** 54,58 **** ns_section "ns/server/${servername}/tcl" ns_param initfile ../nsd/init.tcl ! ns_param library ../tcl ns_section "ns/server/${servername}/module/nssock" --- 55,59 ---- ns_section "ns/server/${servername}/tcl" ns_param initfile ../nsd/init.tcl ! ns_param library [ns_config "test" home]/testserver/modules ns_section "ns/server/${servername}/module/nssock" |
From: Stephen D. <sd...@us...> - 2005-04-18 12:47:18
|
Update of /cvsroot/naviserver/naviserver/tests/testserver/modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23052/tests/testserver/modules Log Message: Directory /cvsroot/naviserver/naviserver/tests/testserver/modules added to the repository |
From: Stephen D. <sd...@us...> - 2005-04-18 12:46:57
|
Update of /cvsroot/naviserver/naviserver/tests/testserver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22919/tests/testserver Log Message: Directory /cvsroot/naviserver/naviserver/tests/testserver added to the repository |
From: Zoran V. <vas...@us...> - 2005-04-17 18:38:57
|
Update of /cvsroot/naviserver/naviserver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21491 Modified Files: ChangeLog Log Message: See file Index: ChangeLog =================================================================== RCS file: /cvsroot/naviserver/naviserver/ChangeLog,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** ChangeLog 17 Apr 2005 08:10:05 -0000 1.48 --- ChangeLog 17 Apr 2005 18:38:49 -0000 1.49 *************** *** 1,4 **** --- 1,9 ---- 2005-04-17 Zoran Vasiljevic <vas...@us...> + * tests/ns_nsv.test: added new file. + Credits to Bernd (b.e...@ki...). + + 2005-04-17 Zoran Vasiljevic <vas...@us...> + * nsd/conn.c: ns_conn status was wrongly returning the changed status code instead of the previous value. |
From: Zoran V. <vas...@us...> - 2005-04-17 18:37:47
|
Update of /cvsroot/naviserver/naviserver/tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20765 Added Files: ns_nsv.test Log Message: Added new file. Credits to Bernd (b.e...@ki...) --- NEW FILE: ns_nsv.test --- # # $Header: /cvsroot/naviserver/naviserver/tests/ns_nsv.test,v 1.1 2005/04/17 18:37:37 vasiljevic Exp $ # package require tcltest 2.2 namespace import -force ::tcltest::* test ns_nsv-1.1 {basic syntax nsv_set} -body { nsv_set } -returnCodes error -result {wrong # args: should be "nsv_set array key ?value?"} test ns_nsv-1.2 {basic syntax nsv_get} -body { nsv_get } -returnCodes error -result {wrong # args: should be "nsv_get array key"} test ns_nsv-1.3 {basic syntax nsv_exists} -body { nsv_exists } -returnCodes error -result {wrong # args: should be "nsv_exists array key"} test ns_nsv-1.4 {basic syntax nsv_append} -body { nsv_append } -returnCodes error -result {wrong # args: should be "nsv_append array key string ?string ...?"} test ns_nsv-1.5 {basic syntax nsv_lappend} -body { nsv_lappend } -returnCodes error -result {wrong # args: should be "nsv_lappend array key string ?string ...?"} test ns_nsv-1.6 {basic syntax nsv_incr} -body { nsv_incr } -returnCodes error -result {wrong # args: should be "nsv_incr array key ?count?"} test ns_nsv-1.7 {basic syntax nsv_unset} -body { nsv_unset } -returnCodes error -result {wrong # args: should be "nsv_unset array ?key?"} test ns_nsv-1.8 {basic syntax nsv_array} -body { nsv_array } -returnCodes error -result {wrong # args: should be "nsv_array option ..."} test ns_nsv-1.9 {basic syntax nsv_names} -body { nsv_names zirrZarr } -result "" test ns_nsv-2.1 {nsv_set a key} -body { nsv_set myarray foo bar } -result "bar" test ns_nsv-2.2 {nsv_set same key} -body { nsv_set myarray foo baz } -result "baz" test ns_nsv-2.3 {nsv_set an "integer" key} -body { nsv_set myarray 1 bar } -result "bar" test ns_nsv-2.4 {nsv_set key with spaces} -body { nsv_set myarray "and now to something different" foo } -result "foo" test ns_nsv-2.5 {nsv_set big value} -body { # set a meg nsv_set myarray twofive [string repeat "x" [expr {1024*1024}]] } -result [string repeat "x" [expr {1024*1024}]] test ns_nsv-3.1 {nsv_unset too many args} -body { nsv_unset myarray foo bar baz } -returnCodes error -result {wrong # args: should be "nsv_unset array ?key?"} test ns_nsv-3.2 {nsv_unset key} -setup { nsv_set threetwo foo bar } -body { nsv_unset threetwo foo } -cleanup { if {[nsv_exists myarray threetwo]} { error "threetwo(threetwo) exists after nsv_unset" } } -result "" test ns_nsv-3.3 {nsv_unset an "integer" key} -setup { nsv_set threethree 1 bar } -body { nsv_unset threethree 1 } -cleanup { if {[nsv_exists threethree 1]} { error "threethree(1) exists after nsv_unset" } } -result "" test ns_nsv-3.4 {nsv_unset key with spaces} -setup { nsv_set threefour "and now to something different" bar } -body { nsv_unset threefour "and now to something different" } -cleanup { if {[nsv_exists threefour "and now to something different"]} { error "threefour(and now to something different) exists after nsv_unset" } } -result "" test ns_nsv-3.5 {nsv_unset array} -setup { nsv_set threefive a1 x nsv_set threefive a2 x nsv_set threefive a3 x nsv_set threefive a4 x nsv_set threefive a5 x } -body { nsv_unset threefive } -cleanup { # don't want to use nsv_array command here. foreach element [list a1 a2 a3 a4 a5] { if {[nsv_exists threefive $element]} { error "threefive($element) exists after 'nsv_unset threefive'" } } } -result "" test ns_nsv-4.1 {nsv_array options} -body { nsv_array zirrZarr } -returnCodes error -result {bad option "zirrZarr": must be set, reset, get, names, size, or exists} test ns_nsv-4.2 {nsv_array set} -body { nsv_array set fourtwo { a 1 b 2 c 3 d 4 e 5 } } -cleanup { foreach element [list a b c d e] { if {![nsv_exists fourtwo $element]} { error "fourtwo($element) does not exist after 'nsv_array set'" } } } -result "" test ns_nsv-4.3 {nsv_array names} -setup { nsv_array set fourthree { a 1 b 2 c 3 d 4 e 5 } } -body { lsort [nsv_array names fourthree] } -result "a b c d e" test ns_nsv-4.4 {nsv_array get} -setup { nsv_array set fourfour { a 1 b 2 c 3 d 4 e 5 } } -body { lsort [nsv_array get fourfour] } -result "1 2 3 4 5 a b c d e" test ns_nsv-4.5 {nsv_array size} -setup { nsv_array set fourfive { a 1 b 2 c 3 d 4 e 5 } } -body { nsv_array size fourfive } -result 5 test ns_nsv-4.6 {nsv_array names reset} -setup { nsv_array set foursix { a 1 b 2 c 3 d 4 e 5 } } -body { array set reset { A 1 B 2 C 3 D 4 E 5 } nsv_array reset foursix [array get reset] lsort [nsv_array get foursix] } -result "1 2 3 4 5 A B C D E" test ns_nsv-4.7 {nsv_array names reset} -setup { nsv_set fourseven foo bar } -body { nsv_array exists fourseven } -result 1 test ns_nsv-5.1 {nsv_get arrayname} -body { nsv_get fiveone } -returnCodes error -result {wrong # args: should be "nsv_get array key"} test ns_nsv-5.2 {nsv_get nonexisting key from nonexisting array} -body { nsv_get fivetwo zirrZarr } -returnCodes error -result {no such array: fivetwo} test ns_nsv-5.3 {nsv_get nonexisting key} -setup { nsv_set fivetwo moo . } -body { nsv_get fivetwo zirrZarr } -returnCodes error -result {no such key: zirrZarr} test ns_nsv-5.4 {nsv_get existing key} -body { nsv_set fivethree foo bar nsv_get fivethree foo } -result "bar" test ns_nsv-6.1 {nsv_exists nonexisting key} -body { nsv_exists sixone foo } -result 0 test ns_nsv-6.2 {nsv_exists existing key} -body { nsv_set sixtwo foo bar nsv_exists sixtwo foo } -result 1 test ns_nsv-7.1 {nsv_append argument syntax} -body { nsv_append foo } -returnCodes error -result {wrong # args: should be "nsv_append array key string ?string ...?"} test ns_nsv-7.2 {nsv_append} -setup { if {[nsv_array exists foo]} { nsv_unset foo } } -body { nsv_append foo bar baz nsv_append foo bar baz nsv_append foo bar baz } -result "bazbazbaz" test ns_nsv-8.1 {nsv_lappend argument syntax} -body { nsv_lappend foo } -returnCodes error -result {wrong # args: should be "nsv_lappend array key string ?string ...?"} test ns_nsv-8.2 {nsv_lappend} -setup { if {[nsv_array exists foo]} { nsv_unset foo } } -body { nsv_lappend foo bar baz nsv_lappend foo bar baz nsv_lappend foo bar baz } -result "baz baz baz" test ns_nsv-8.3 {nsv_lappend number of elements} -setup { if {[nsv_array exists foo]} { nsv_unset foo } } -body { nsv_lappend foo bar [list a 1] nsv_lappend foo bar [list b 2] nsv_lappend foo bar [list c 3] llength [nsv_get foo bar] } -result 3 test ns_nsv-9.1 {nsv_incr without count} -setup { if {[nsv_exists foo bar]} { nsv_unset foo bar } } -body { nsv_incr foo bar nsv_incr foo bar nsv_incr foo bar } -result 3 test ns_nsv-9.2 {nsv_incr with positive count} -setup { if {[nsv_exists foo bar]} { nsv_unset foo bar } } -body { nsv_incr foo bar +10 nsv_incr foo bar +20 nsv_incr foo bar +30 } -result 60 test ns_nsv-9.3 {nsv_incr with negative count} -setup { if {[nsv_exists foo bar]} { nsv_unset foo bar } } -body { nsv_incr foo bar -10 nsv_incr foo bar -20 nsv_incr foo bar -30 } -result "-60" test ns_nsv-9.4 {nsv_incr with unrepresentable count} -setup { if {[nsv_exists foo bar]} { nsv_unset foo bar } } -body { nsv_incr foo bar +1000000000000 } -returnCodes error -result {integer value too large to represent} test ns_nsv-9.5 {nsv_incr from negative to positive} -setup { if {[nsv_exists foo bar]} { nsv_unset foo bar } nsv_set foo bar -60 } -body { nsv_incr foo bar nsv_incr foo bar nsv_incr foo bar } -result "-57" test ns_nsv-9.6 {nsv_incr type mismatch} -setup { if {[nsv_exists foo bar]} { nsv_unset foo bar } } -body { nsv_incr foo bar a } -returnCodes error -result {expected integer but got "a"} test ns_nsv-9.7 {nsv_incr by zero} -setup { if {[nsv_exists foo bar]} { nsv_unset foo bar } } -body { nsv_incr foo bar +000 nsv_incr foo bar +00 nsv_incr foo bar +0 } -result 0 test ns_nsv-10.1 {nsv_names} -setup { foreach key [list aaa bbb ccc aaaAAA bbbBBB cccCCC] { if {[nsv_array exists $key]} { nsv_unset $key } nsv_set $key x y } } -match regexp -body { nsv_names } -result "cccCCC|bbbBBB|aaaAAA|ccc|bbb|aaa" test ns_nsv-10.2 {nsv_names} -setup { foreach key [list aaa bbb ccc aaaAAA bbbBBB cccCCC] { if {[nsv_array exists $key]} { nsv_unset $key } nsv_set $key x y } } -body { nsv_names ccc } -result "ccc" test ns_nsv-10.3 {nsv_names} -setup { foreach key [list aaa bbb ccc aaaAAA bbbBBB cccCCC] { if {[nsv_array exists $key]} { nsv_unset $key } nsv_set $key x y } } -body { nsv_names ccc* } -result "ccc cccCCC" cleanupTests |
From: Zoran V. <vas...@us...> - 2005-04-17 08:10:14
|
Update of /cvsroot/naviserver/naviserver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17405 Modified Files: ChangeLog Log Message: ns_conn status <value> will now return the previous status before setting the new status as it did before. Index: ChangeLog =================================================================== RCS file: /cvsroot/naviserver/naviserver/ChangeLog,v retrieving revision 1.47 retrieving revision 1.48 diff -C2 -d -r1.47 -r1.48 *** ChangeLog 16 Apr 2005 15:23:57 -0000 1.47 --- ChangeLog 17 Apr 2005 08:10:05 -0000 1.48 *************** *** 1,2 **** --- 1,8 ---- + 2005-04-17 Zoran Vasiljevic <vas...@us...> + + * nsd/conn.c: ns_conn status was wrongly returning the + changed status code instead of the previous value. + This was introduced (again) by the changes below. + 2005-04-16 Zoran Vasiljevic <vas...@us...> |
From: Zoran V. <vas...@us...> - 2005-04-17 08:10:14
|
Update of /cvsroot/naviserver/naviserver/nsd In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17405/nsd Modified Files: conn.c Log Message: ns_conn status <value> will now return the previous status before setting the new status as it did before. Index: conn.c =================================================================== RCS file: /cvsroot/naviserver/naviserver/nsd/conn.c,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** conn.c 16 Apr 2005 14:51:03 -0000 1.9 --- conn.c 17 Apr 2005 08:10:05 -0000 1.10 *************** *** 1254,1260 **** return TCL_ERROR; } Ns_ConnSetResponseStatus(conn, status); } - Tcl_SetIntObj(result, Ns_ConnResponseStatus(conn)); break; --- 1254,1262 ---- return TCL_ERROR; } + Tcl_SetIntObj(result, Ns_ConnResponseStatus(conn)); Ns_ConnSetResponseStatus(conn, status); + } else { + Tcl_SetIntObj(result, Ns_ConnResponseStatus(conn)); } break; |
From: Zoran V. <vas...@us...> - 2005-04-16 15:24:05
|
Update of /cvsroot/naviserver/naviserver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4609 Modified Files: ChangeLog Log Message: See file Index: ChangeLog =================================================================== RCS file: /cvsroot/naviserver/naviserver/ChangeLog,v retrieving revision 1.46 retrieving revision 1.47 diff -C2 -d -r1.46 -r1.47 *** ChangeLog 16 Apr 2005 09:21:36 -0000 1.46 --- ChangeLog 16 Apr 2005 15:23:57 -0000 1.47 *************** *** 4,7 **** --- 4,10 ---- which caused some older gcc compilers to break. + * nsd/conn.c: added "ns_conn flush" as per RFE #1184271 + and untabified and reidented the file (eh, old nit-picker) + 2005-04-11 Stephen Deasey <sd...@us...> |
From: Zoran V. <vas...@us...> - 2005-04-16 14:51:11
|
Update of /cvsroot/naviserver/naviserver/nsd In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20257 Modified Files: conn.c Log Message: Untabify, re-ident and cleanup (make it looks more decent than it was). Index: conn.c =================================================================== RCS file: /cvsroot/naviserver/naviserver/nsd/conn.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** conn.c 16 Apr 2005 14:05:25 -0000 1.8 --- conn.c 16 Apr 2005 14:51:03 -0000 1.9 *************** *** 41,46 **** static int GetChan(Tcl_Interp *interp, char *id, Tcl_Channel *chanPtr); static int GetIndices(Tcl_Interp *interp, Conn *connPtr, Tcl_Obj **objv, ! int *offPtr, int *lenPtr); ! static int MakeConnChan(Tcl_Interp *interp, Ns_Conn *conn); --- 41,46 ---- static int GetChan(Tcl_Interp *interp, char *id, Tcl_Channel *chanPtr); static int GetIndices(Tcl_Interp *interp, Conn *connPtr, Tcl_Obj **objv, ! int *offPtr, int *lenPtr); [...2117 lines suppressed...] { int sock; /* ! * Flush the connection, so we can safely make a dup of the socket. ! * Without this, we may dup some unwanted data in socket buffers ! * which may confuse the receiving side. */ Ns_WriteConn(conn, NULL, 0); sock = ns_sockdup(Ns_ConnSock(conn)); if (sock == INVALID_SOCKET) { ! return NULL; } Ns_SockSetBlocking(sock); ! return Tcl_MakeTcpClientChannel((ClientData)sock); } |
From: Zoran V. <vas...@us...> - 2005-04-16 14:05:45
|
Update of /cvsroot/naviserver/naviserver/nsd In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27421 Modified Files: conn.c Log Message: Added "ns_conn flush" as per RFE #1184271 and improved "ns_conn status" argument checking. Index: conn.c =================================================================== RCS file: /cvsroot/naviserver/naviserver/nsd/conn.c,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** conn.c 12 Apr 2005 06:21:23 -0000 1.7 --- conn.c 16 Apr 2005 14:05:25 -0000 1.8 *************** *** 1,7 **** /* ! * 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" --- 1,7 ---- /* ! * The contents of this file are subject to the Mozilla 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://www.mozilla.org/. * * Software distributed under the License is distributed on an "AS IS" *************** *** 235,238 **** --- 235,239 ---- } + /* *---------------------------------------------------------------------- *************** *** 293,297 **** * * Results: ! * integer, number of bytes to send * * Side effects: --- 294,298 ---- * * Results: ! * Integer, number of bytes to send * * Side effects: *************** *** 946,967 **** static CONST char *opts[] = { "authpassword", "authuser", "close", "content", "contentlength", ! "copy", "driver", "encoding", "files", "fileoffset", ! "filelength", "fileheaders", "flags", "form", "headers", "host", "id", "isconnected", "location", "method", "outputheaders", "peeraddr", "peerport", "port", "protocol", "query", "request", "server", "sock", "start", "status", ! "url", "urlc", "urlencoding", "urlv", "version", "write_encoded", ! "channel", NULL }; enum ISubCmdIdx { CAuthPasswordIdx, CAuthUserIdx, CCloseIdx, CContentIdx, ! CContentLengthIdx, CCopyIdx, CDriverIdx, CEncodingIdx, CFilesIdx, CFileOffIdx, CFileLenIdx, CFileHdrIdx, CFlagsIdx, ! CFormIdx, CHeadersIdx, CHostIdx, CIdIdx, CIsConnectedIdx, CLocationIdx, CMethodIdx, COutputHeadersIdx, CPeerAddrIdx, CPeerPortIdx, CPortIdx, CProtocolIdx, CQueryIdx, CRequestIdx, CServerIdx, CSockIdx, CStartIdx, CStatusIdx, CUrlIdx, ! CUrlcIdx, CUrlEncodingIdx, CUrlvIdx, CVersionIdx, CWriteEncodedIdx, ! CChannelIdx } opt; --- 947,966 ---- static CONST char *opts[] = { "authpassword", "authuser", "close", "content", "contentlength", ! "copy", "channel", "driver", "encoding", "files", "fileoffset", ! "filelength", "fileheaders", "flags", "form", "flush", "headers", "host", "id", "isconnected", "location", "method", "outputheaders", "peeraddr", "peerport", "port", "protocol", "query", "request", "server", "sock", "start", "status", ! "url", "urlc", "urlencoding", "urlv", "version", "write_encoded", NULL }; enum ISubCmdIdx { CAuthPasswordIdx, CAuthUserIdx, CCloseIdx, CContentIdx, ! CContentLengthIdx, CCopyIdx, CChannelIdx, CDriverIdx, CEncodingIdx, CFilesIdx, CFileOffIdx, CFileLenIdx, CFileHdrIdx, CFlagsIdx, ! CFormIdx, CFlushIdx, CHeadersIdx, CHostIdx, CIdIdx, CIsConnectedIdx, CLocationIdx, CMethodIdx, COutputHeadersIdx, CPeerAddrIdx, CPeerPortIdx, CPortIdx, CProtocolIdx, CQueryIdx, CRequestIdx, CServerIdx, CSockIdx, CStartIdx, CStatusIdx, CUrlIdx, ! CUrlcIdx, CUrlEncodingIdx, CUrlvIdx, CVersionIdx, CWriteEncodedIdx } opt; *************** *** 1157,1160 **** --- 1156,1166 ---- break; + case CFlushIdx: { + Tcl_SetIntObj(result, + Ns_ConnFlushHeaders(conn, + Ns_ConnResponseStatus(conn))); + break; + } + case CCopyIdx: if (objc != 5) { *************** *** 1167,1173 **** } if (Tcl_Write(chan, connPtr->reqPtr->content + off, len) != len) { ! Tcl_AppendResult(interp, "could not write ", Tcl_GetString(objv[3]), " bytes to ", ! Tcl_GetString(objv[4]), ": ", Tcl_PosixError(interp), NULL); ! return TCL_ERROR; } break; --- 1173,1181 ---- } if (Tcl_Write(chan, connPtr->reqPtr->content + off, len) != len) { ! Tcl_AppendResult(interp, "could not write ", ! Tcl_GetString(objv[3]), " bytes to ", ! Tcl_GetString(objv[4]), ": ", ! Tcl_PosixError(interp), NULL); ! return TCL_ERROR; } break; *************** *** 1240,1254 **** break; ! case CStatusIdx: ! if (objc > 2) { ! int new_status; ! if (Tcl_GetIntFromObj(interp, objv[2], &new_status) != TCL_OK) { ! Tcl_AppendResult(interp, "Invalid response status code", NULL ); ! return TCL_ERROR; ! } ! Ns_ConnSetResponseStatus(conn, new_status); } ! Tcl_SetIntObj(result, Ns_ConnResponseStatus(conn)); ! break; case CSockIdx: --- 1248,1264 ---- break; ! case CStatusIdx: ! if (objc < 2 || objc > 3) { ! Tcl_WrongNumArgs(interp, 2, objv, "?status?"); ! return TCL_ERROR; ! } else if (objc == 3) { ! int status; ! if (Tcl_GetIntFromObj(interp, objv[2], &status) != TCL_OK) { ! return TCL_ERROR; } ! Ns_ConnSetResponseStatus(conn, status); ! } ! Tcl_SetIntObj(result, Ns_ConnResponseStatus(conn)); ! break; case CSockIdx: |
From: Zoran V. <vas...@us...> - 2005-04-16 09:21:46
|
Update of /cvsroot/naviserver/naviserver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8303 Modified Files: ChangeLog Log Message: See file Index: ChangeLog =================================================================== RCS file: /cvsroot/naviserver/naviserver/ChangeLog,v retrieving revision 1.45 retrieving revision 1.46 diff -C2 -d -r1.45 -r1.46 *** ChangeLog 12 Apr 2005 06:21:22 -0000 1.45 --- ChangeLog 16 Apr 2005 09:21:36 -0000 1.46 *************** *** 1,2 **** --- 1,7 ---- + 2005-04-16 Zoran Vasiljevic <vas...@us...> + + * nsd/nsmain.c: removed extra colon in variable declaration + which caused some older gcc compilers to break. + 2005-04-11 Stephen Deasey <sd...@us...> |
From: Zoran V. <vas...@us...> - 2005-04-16 09:20:13
|
Update of /cvsroot/naviserver/naviserver/nsd In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7182 Modified Files: nsmain.c Log Message: Removed extra colon in variable declaration which caused older gcc compilers to break. Index: nsmain.c =================================================================== RCS file: /cvsroot/naviserver/naviserver/nsd/nsmain.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** nsmain.c 9 Apr 2005 16:35:06 -0000 1.8 --- nsmain.c 16 Apr 2005 09:20:04 -0000 1.9 *************** *** 110,114 **** { int i, fd, sig, optind, cmdargc; ! char **cmdargv;; char *config; Ns_Time timeout; --- 110,114 ---- { int i, fd, sig, optind, cmdargc; ! char **cmdargv; char *config; Ns_Time timeout; |
From: Stephen D. <sd...@us...> - 2005-04-12 06:21:36
|
Update of /cvsroot/naviserver/naviserver/nsd In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22726/nsd Modified Files: conn.c fastpath.c info.c nsd.h pathname.c proc.c return.c server.c tclcmds.c Log Message: * include/ns.h: * nsd/nsd.h: * nsd/info.c: * nsd/proc.c: * nsd/return.c: * nsd/server.c: * nsd/fastpath.c: * nsd/pathname.c: New concept: server root. Callback can be registered to create the server root, defaults to statically assigned 'serverroot' from config, or host-based if enabled. Many virtual hosting options added. (RFE #1159471) * nsd/conn.c: Add callback to generate current location. If none registered, uses host-header and falls back to driver's location. Add new Ns_ConnAppendLocation() as preferred method of access, depreciated Ns_ConnLocation(). * nsd/tclcmds.c: Add vhost related Tcl commands: ns_serverpath ns_pagepath ns_hashpath ns_serverrootproc ns_locationproc. * ns_pagepath.test: * ns_conn_host.test: * ns_serverpath.test: * ns_hashpath.test: * tests/test.nscfg: Add tests for vhost related commands. More location tests needed... Index: return.c =================================================================== RCS file: /cvsroot/naviserver/naviserver/nsd/return.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** return.c 18 Mar 2005 08:21:06 -0000 1.2 --- return.c 12 Apr 2005 06:21:23 -0000 1.3 *************** *** 697,705 **** */ if (servPtr->opts.noticedetail) { ! Ns_DStringVarAppend(&ds, "<P ALIGN=RIGHT><SMALL><I>", ! Ns_InfoServerName(), "/", ! Ns_InfoServerVersion(), " on ", ! Ns_ConnLocation(conn), "</I></SMALL></P>\n", ! NULL); } --- 697,706 ---- */ if (servPtr->opts.noticedetail) { ! Ns_DStringVarAppend(&ds, "<P ALIGN=RIGHT><SMALL><I>", ! Ns_InfoServerName(), "/", ! Ns_InfoServerVersion(), " on ", ! NULL); ! Ns_ConnLocationAppend(conn, &ds); ! Ns_DStringAppend(&ds, "</I></SMALL></P>\n"); } *************** *** 950,965 **** if (url != NULL) { if (*url == '/') { ! Ns_DStringAppend(&ds, Ns_ConnLocation(conn)); } Ns_DStringAppend(&ds, url); Ns_ConnSetHeaders(conn, "Location", ds.string); ! Ns_DStringVarAppend(&msg, "<A HREF=\"", ds.string, ! "\">The requested URL has moved here.</A>", NULL); ! result = Ns_ConnReturnNotice(conn, 302, "Redirection", msg.string); } else { ! result = Ns_ConnReturnNotice(conn, 204, "No Content", msg.string); } Ns_DStringFree(&msg); Ns_DStringFree(&ds); return result; } --- 951,967 ---- if (url != NULL) { if (*url == '/') { ! Ns_ConnLocationAppend(conn, &ds); } Ns_DStringAppend(&ds, url); Ns_ConnSetHeaders(conn, "Location", ds.string); ! Ns_DStringVarAppend(&msg, "<A HREF=\"", ds.string, ! "\">The requested URL has moved here.</A>", NULL); ! result = Ns_ConnReturnNotice(conn, 302, "Redirection", msg.string); } else { ! result = Ns_ConnReturnNotice(conn, 204, "No Content", msg.string); } Ns_DStringFree(&msg); Ns_DStringFree(&ds); + return result; } Index: nsd.h =================================================================== RCS file: /cvsroot/naviserver/naviserver/nsd/nsd.h,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** nsd.h 8 Apr 2005 19:59:16 -0000 1.10 --- nsd.h 12 Apr 2005 06:21:23 -0000 1.11 *************** *** 133,136 **** --- 133,139 ---- #define LOG_USEC 32 + #define NSD_STRIP_WWW 0x01 + #define NSD_STRIP_PORT 0x02 + /* * The following is the default text/html content type *************** *** 508,512 **** typedef struct NsServer { char *server; - Ns_LocationProc *locationProc; /* --- 511,514 ---- *************** *** 559,563 **** struct { ! char *pageroot; char **dirv; int dirc; --- 561,567 ---- struct { ! char *serverdir; /* virtual server files path */ ! char *pagedir; /* path to public pages */ ! char *pageroot; /* absolute path to public pages */ char **dirv; int dirc; *************** *** 571,574 **** --- 575,594 ---- /* + * The following struct maintains virtual host config. + */ + + struct { + bool enabled; + int opts; /* NSD_STRIP_WWW | NSD_STRIP_PORT */ + char *hostprefix; + int hosthashlevel; + Ns_ServerRootProc *serverRootProc; + void *serverRootArg; + Ns_ConnLocationProc *connLocationProc; + void *connLocationArg; + Ns_LocationProc *locationProc; /* depreciated */ + } vhost; + + /* * The following struct maintains request tables. */ *************** *** 827,835 **** --- 847,859 ---- extern int NsUrlToFile(Ns_DString *dsPtr, NsServer *servPtr, char *url); + extern char *NsPageRoot(Ns_DString *dest, NsServer *servPtr, char *host); + /* * External callback functions. */ + extern Ns_ConnLocationProc NsTclConnLocation; extern Ns_SchedProc NsTclSchedProc; + extern Ns_ServerRootProc NsTclServerRoot; extern Ns_ThreadProc NsTclThread; extern Ns_ArgProc NsTclThreadArgProc; Index: conn.c =================================================================== RCS file: /cvsroot/naviserver/naviserver/nsd/conn.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** conn.c 18 Mar 2005 08:12:56 -0000 1.6 --- conn.c 12 Apr 2005 06:21:23 -0000 1.7 *************** *** 364,386 **** * Ns_SetConnLocationProc -- * ! * Set pointer to custom routine that acts like Ns_ConnLocation(); * * Results: ! * None. * * Side effects: ! * None. * *---------------------------------------------------------------------- */ ! void ! Ns_SetConnLocationProc(Ns_LocationProc *procPtr) { NsServer *servPtr = NsGetInitServer(); ! if (servPtr != NULL) { ! servPtr->locationProc = procPtr; } } --- 364,392 ---- * Ns_SetConnLocationProc -- * ! * Set pointer to custom routine that acts like ! * Ns_ConnLocationAppend(); * * Results: ! * NS_OK or NS_ERROR. * * Side effects: ! * Overrides an old-style Ns_LocationProc. * *---------------------------------------------------------------------- */ ! int ! Ns_SetConnLocationProc(Ns_ConnLocationProc *proc, void *arg) { NsServer *servPtr = NsGetInitServer(); ! if (servPtr == NULL) { ! Ns_Log(Error, "Ns_SetConnLocationProc: no initializing server"); ! return NS_ERROR; } + servPtr->vhost.connLocationProc = proc; + servPtr->vhost.connLocationArg = arg; + + return NS_OK; } *************** *** 392,395 **** --- 398,404 ---- * Set pointer to custom routine that acts like Ns_ConnLocation(); * + * Depreciated: Use Ns_SetConnLocationProc() which is virtual host + * aware. + * * Results: * None. *************** *** 402,411 **** void ! Ns_SetLocationProc(char *server, Ns_LocationProc *procPtr) { NsServer *servPtr = NsGetServer(server); if (servPtr != NULL) { ! servPtr->locationProc = procPtr; } } --- 411,420 ---- void ! Ns_SetLocationProc(char *server, Ns_LocationProc *proc) { NsServer *servPtr = NsGetServer(server); if (servPtr != NULL) { ! servPtr->vhost.locationProc = proc; } } *************** *** 417,428 **** * Ns_ConnLocation -- * ! * Get the location of this connection. It is of the form ! * METHOD://HOSTNAME:PORT * * Results: ! * a string URL, not including path * * Side effects: ! * None. * *---------------------------------------------------------------------- --- 426,440 ---- * Ns_ConnLocation -- * ! * Get the location according to the driver for this connection. ! * It is of the form SCHEME://HOSTNAME:PORT ! * ! * Depreciated: Use Ns_ConnLocationAppend() which is virtual host ! * aware. * * Results: ! * a string URL, not including path * * Side effects: ! * None. * *---------------------------------------------------------------------- *************** *** 432,444 **** Ns_ConnLocation(Ns_Conn *conn) { ! Conn *connPtr = (Conn *) conn; NsServer *servPtr = connPtr->servPtr; ! char *location; - if (servPtr->locationProc != NULL) { - location = (*servPtr->locationProc)(conn); } else { ! location = connPtr->location; } return location; } --- 444,552 ---- Ns_ConnLocation(Ns_Conn *conn) { ! Conn *connPtr = (Conn *) conn; NsServer *servPtr = connPtr->servPtr; ! char *location = NULL; ! ! if (servPtr->vhost.locationProc != NULL) { ! location = (*servPtr->vhost.locationProc)(conn); ! } ! if (location == NULL) { ! location = connPtr->location; ! } ! ! return location; ! } ! ! ! /* ! *---------------------------------------------------------------------- ! * ! * Ns_ConnLocationAppend -- ! * ! * Append the location of this connection to dest. It is of the ! * form SCHEME://HOSTNAME:PORT ! * ! * Results: ! * dest->string. ! * ! * Side effects: ! * None. ! * ! *---------------------------------------------------------------------- ! */ ! ! char * ! Ns_ConnLocationAppend(Ns_Conn *conn, Ns_DString *dest) ! { ! Conn *connPtr = (Conn *) conn; ! NsServer *servPtr = connPtr->servPtr; ! Ns_Set *headers; ! char *location, *host, *p; ! ! if (servPtr->vhost.connLocationProc != NULL) { ! ! /* ! * Prefer the new style Ns_ConnLocationProc. ! */ ! ! location = (*servPtr->vhost.connLocationProc) ! (conn, dest, servPtr->vhost.connLocationArg); ! if (location == NULL) { ! goto deflocation; ! } ! ! } else if (servPtr->vhost.locationProc != NULL) { ! ! /* ! * Fall back to old style Ns_LocationProc. ! */ ! ! location = (*servPtr->vhost.locationProc)(conn); ! if (location == NULL) { ! goto deflocation; ! } ! location = Ns_DStringAppend(dest, location); ! ! } else if (servPtr->vhost.enabled ! && (headers = Ns_ConnHeaders(conn)) ! && (host = Ns_SetIGet(headers, "Host")) ! && *host != '\0') { ! ! /* ! * Construct a location string from the HTTP host header. ! * ! * We do not trust the contents of the Host header, so we scan ! * it for new lines which may be a reponse splitting attack when ! * used as the target of a redirect reponse, and the HTML open ! * tag character which may be a cross-site scripting attack when ! * embedded within HTML. ! */ ! ! for (p = host; *p != '\0'; ++p) { ! if (*p == '\n' || *p == '\r' || *p == '<') { ! return NULL; ! } ! } ! ! Ns_DStringAppend(dest, connPtr->location); ! location = strstr(dest->string, "://"); ! if (location != NULL) { ! Ns_DStringTrunc(dest, (location - dest->string) + 3); ! } else { ! /* server missconfiguration, should begin: SCHEME:// */ ! Ns_DStringAppend(dest, "http://"); ! } ! location = Ns_DStringAppend(dest, host); } else { ! ! /* ! * If all else fails, append the static driver location. ! */ ! ! deflocation: ! location = Ns_DStringAppend(dest, connPtr->location); } + return location; } *************** *** 833,836 **** --- 941,945 ---- Tcl_HashSearch search; FormFile *filePtr; + Ns_DString ds; int idx, off, len; *************** *** 1118,1122 **** case CLocationIdx: ! Tcl_SetResult(interp, Ns_ConnLocation(conn), TCL_STATIC); break; --- 1227,1233 ---- case CLocationIdx: ! Ns_DStringInit(&ds); ! Ns_ConnLocationAppend(conn, &ds); ! Tcl_DStringResult(interp, &ds); break; *************** *** 1178,1181 **** --- 1289,1330 ---- *---------------------------------------------------------------------- * + * NsTclLocationProcObjCmd -- + * + * Implements ns_locationproc as obj command. + * + * Results: + * Tcl result. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + + int + NsTclLocationProcObjCmd(ClientData arg, Tcl_Interp *interp, int objc, Tcl_Obj **objv) + { + NsServer *servPtr = NsGetInitServer(); + Ns_TclCallback *cbPtr; + + if (objc != 2 && objc != 3) { + Tcl_WrongNumArgs(interp, 1, objv, "script ?arg?"); + return TCL_ERROR; + } + if (servPtr == NULL) { + Tcl_AppendResult(interp, "no initializing server", TCL_STATIC); + return TCL_ERROR; + } + cbPtr = Ns_TclNewCallbackObj(interp, NsTclConnLocation, + objv[1], (objc > 2) ? objv[2] : NULL); + Ns_SetConnLocationProc(NsTclConnLocation, cbPtr); + + return TCL_OK; + } + + + /* + *---------------------------------------------------------------------- + * * NsTclWriteContentObjCmd -- * *************** *** 1327,1330 **** --- 1476,1507 ---- } + + /* + *---------------------------------------------------------------------- + * + * NsTclConnLocation -- + * + * Tcl callback to construct location string. + * + * Results: + * dest->string or NULL on error. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + + char * + NsTclConnLocation(Ns_Conn *conn, Ns_DString *dest, void *arg) + { + Ns_TclCallback *cbPtr = arg; + Tcl_Interp *interp = Ns_GetConnInterp(conn); + + if (Ns_TclEvalCallback(interp, cbPtr, dest, NULL) != NS_OK) { + return NULL; + } + return Ns_DStringValue(dest); + } Index: pathname.c =================================================================== RCS file: /cvsroot/naviserver/naviserver/nsd/pathname.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** pathname.c 16 Feb 2005 08:40:22 -0000 1.1.1.1 --- pathname.c 12 Apr 2005 06:21:23 -0000 1.2 *************** *** 45,49 **** --- 45,53 ---- */ + static int PathObjCmd(ClientData arg, Tcl_Interp *interp, int objc, + Tcl_Obj *CONST objv[], int cmd); static char *MakePath(Ns_DString *dest, va_list *pap); + static char *ServerRoot(Ns_DString *dest, NsServer *servPtr, char *host); + *************** *** 202,205 **** --- 206,258 ---- *---------------------------------------------------------------------- * + * Ns_HashPath -- + * + * Hash the leading characters of string into a path, skipping + * periods and slashes. If string contains less characters than + * levels requested, '_' characters are used as padding. + * + * For example, given the string 'foo' and the levels 2, 3, 4: + * + * foo, 2 -> /f/o + * foo, 3 -> /f/o/o + * foo, 4 -> /f/o/o/_ + * + * Results: + * dest->string + * + * Side effects: + * Will append to dest. + * + *---------------------------------------------------------------------- + */ + + char * + Ns_HashPath(Ns_DString *dest, char *string, int levels) + { + char *p = string; + int i; + + for (i = 0; i < levels; ++i) { + if (dest->string[dest->length] != '/') { + Ns_DStringNAppend(dest, "/", 1); + } + while (*p == '.' || isslash(*p)) { + ++p; + } + if (*p != '\0') { + Ns_DStringNAppend(dest, p, 1); + p++; + } else { + Ns_DStringNAppend(dest, "_", 1); + } + } + + return Ns_DStringValue(dest); + } + + + /* + *---------------------------------------------------------------------- + * * Ns_LibPath -- * *************** *** 266,269 **** --- 319,394 ---- *---------------------------------------------------------------------- * + * Ns_ServerPath -- + * + * Build a path relative to the server root dir. + * + * Results: + * dest->string or NULL on error. + * + * Side effects: + * See ServerRoot(). + * + *---------------------------------------------------------------------- + */ + + char * + Ns_ServerPath(Ns_DString *dest, char *server, ...) + { + NsServer *servPtr; + va_list ap; + char *path; + + servPtr = NsGetServer(server); + if (servPtr == NULL) { + return NULL; + } + ServerRoot(dest, servPtr, NULL); + va_start(ap, server); + path = MakePath(dest, &ap); + va_end(ap); + + return path; + } + + + /* + *---------------------------------------------------------------------- + * + * Ns_PagePath -- + * + * Build a path relative to the server pages dir. + * + * Results: + * dest->string or NULL on error. + * + * Side effects: + * See ServerRoot(). + * + *---------------------------------------------------------------------- + */ + + char * + Ns_PagePath(Ns_DString *dest, char *server, ...) + { + NsServer *servPtr; + va_list ap; + char *path; + + servPtr = NsGetServer(server); + if (servPtr == NULL) { + return NULL; + } + NsPageRoot(dest, servPtr, NULL); + va_start(ap, server); + path = MakePath(dest, &ap); + va_end(ap); + + return path; + } + + + /* + *---------------------------------------------------------------------- + * * Ns_ModulePath -- * *************** *** 304,307 **** --- 429,539 ---- *---------------------------------------------------------------------- * + * Ns_SetServerRootProc -- + * + * Set pointer to custom procedure that returns the root dir path + * for a server. + * + * Results: + * None. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + + int + Ns_SetServerRootProc(Ns_ServerRootProc *proc, void *arg) + { + NsServer *servPtr = NsGetInitServer(); + + if (servPtr == NULL) { + Ns_Log(Error, "Ns_SetServerRootProc: no initializing server"); + return NS_ERROR; + } + servPtr->vhost.serverRootProc = proc; + servPtr->vhost.serverRootArg = arg; + + return NS_OK; + } + + + /* + *---------------------------------------------------------------------- + * + * NsPageRoot -- + * + * Return the path to the server pages directory. + * + * Results: + * dest->string. + * + * Side effects: + * See ServerRoot(). + * + *---------------------------------------------------------------------- + */ + + char * + NsPageRoot(Ns_DString *dest, NsServer *servPtr, char *host) + { + char *path; + + if (Ns_PathIsAbsolute(servPtr->fastpath.pagedir)) { + path = Ns_DStringAppend(dest, servPtr->fastpath.pagedir); + } else { + ServerRoot(dest, servPtr, host); + path = Ns_MakePath(dest, servPtr->fastpath.pagedir, NULL); + } + + return path; + } + + + /* + *---------------------------------------------------------------------- + * + * NsTclHashPathObjCmd -- + * + * Implements ns_hashpath obj command; a wrapper for Ns_HashPath. + * + * Results: + * Tcl result. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + + + int + NsTclHashPathObjCmd(ClientData arg, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) + { + Ns_DString path; + int levels; + + if (objc != 3) { + Tcl_WrongNumArgs(interp, 1, objv, "string levels"); + return TCL_ERROR; + } + if (Tcl_GetIntFromObj(interp, objv[2], &levels) != TCL_OK + || levels <= 0) { + + Tcl_SetResult(interp, "levels must be an interger greater than zero", + TCL_STATIC); + return TCL_ERROR; + } + Ns_DStringInit(&path); + Ns_HashPath(&path, Tcl_GetString(objv[1]), levels); + Tcl_DStringResult(interp, &path); + + return TCL_OK; + } + + + /* + *---------------------------------------------------------------------- + * * NsTclModulePathObjCmd -- * *************** *** 345,348 **** --- 577,719 ---- *---------------------------------------------------------------------- * + * NsTclServerPathObjCmd, NsTclPagePathObjCmd -- + * + * Implements ns_serverpath, ns_pagepath commands. + * + * Results: + * Tcl result. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + + + int + NsTclServerPathObjCmd(ClientData arg, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) + { + return PathObjCmd(arg, interp, objc, objv, 's'); + } + + int + NsTclPagePathObjCmd(ClientData arg, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) + { + return PathObjCmd(arg, interp, objc, objv, 'p'); + } + + static int + PathObjCmd(ClientData arg, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[], int cmd) + { + NsInterp *itPtr = arg; + NsServer *servPtr; + Ns_DString ds; + char *path, *host = NULL; + int i, npaths = 0; + + Ns_ObjvSpec opts[] = { + {"-host", Ns_ObjvString, &host, NULL}, + {"--", Ns_ObjvBreak, NULL, NULL}, + {NULL, NULL, NULL, NULL} + }; + Ns_ObjvSpec args[] = { + {"?path", Ns_ObjvArgs, &npaths, NULL}, + {NULL, NULL, NULL, NULL} + }; + if (Ns_ParseObjv(opts, args, interp, 1, objc, objv) != NS_OK) { + return TCL_ERROR; + } + + if ((servPtr = itPtr->servPtr) == NULL + && (servPtr = NsGetInitServer()) == NULL) { + + Tcl_SetResult(interp, "no server available", TCL_STATIC); + return TCL_ERROR; + } + + Ns_DStringInit(&ds); + if (cmd == 'p') { + path = NsPageRoot(&ds, itPtr->servPtr, host); + } else { + path = ServerRoot(&ds, itPtr->servPtr, host); + } + for (i = objc - npaths; i < objc; ++i) { + Ns_MakePath(&ds, Tcl_GetString(objv[i]), NULL); + } + Tcl_DStringResult(interp, &ds); + + return TCL_OK; + } + + + /* + *---------------------------------------------------------------------- + * + * NsTclServerRootProcObjCmd -- + * + * Implements the ns_serverrootproc command. + * + * Results: + * Tcl result. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + + int + NsTclServerRootProcObjCmd(ClientData arg, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) + { + NsServer *servPtr = NsGetInitServer(); + Ns_TclCallback *cbPtr; + + if (objc != 2 && objc != 3) { + Tcl_WrongNumArgs(interp, 1, objv, "script ?arg?"); + return TCL_ERROR; + } + if (servPtr == NULL) { + Tcl_AppendResult(interp, "no initializing server", TCL_STATIC); + return TCL_ERROR; + } + cbPtr = Ns_TclNewCallbackObj(interp, NsTclServerRoot, + objv[1], (objc > 2) ? objv[2] : NULL); + Ns_SetServerRootProc(NsTclServerRoot, cbPtr); + + return TCL_OK; + } + + + /* + *---------------------------------------------------------------------- + * + * NsTclServerRoot -- + * + * Tcl callback to build a path to the server root dir. + * + * Results: + * dest->string or NULL on error. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + + char * + NsTclServerRoot(Ns_DString *dest, char *host, void *arg) + { + Ns_TclCallback *cbPtr = arg; + + if (Ns_TclEvalCallback(NULL, cbPtr, dest, host, NULL) != NS_OK) { + return NULL; + } + return Ns_DStringValue(dest); + } + + + /* + *---------------------------------------------------------------------- + * * MakePath -- * *************** *** 389,390 **** --- 760,853 ---- return dest->string; } + + + /* + *---------------------------------------------------------------------- + * ServerRoot -- + * + * Return the path to the server root directory. If virtual + * hosting is enabled then the host header is used to construct the + * path. If host is given it overides the Host header of the + * current connection. + * + * Results: + * dest->string. + * + * Side effects: + * Value of Host header may be bashed to lower case. + * Depends on registered Ns_ServerRootProc, if any. + * + *---------------------------------------------------------------------- + */ + + static char * + ServerRoot(Ns_DString *dest, NsServer *servPtr, char *host) + { + char *p, *path, *port = NULL; + Ns_Conn *conn; + Ns_Set *headers; + + if (servPtr->vhost.serverRootProc != NULL) { + + /* + * Prefer to run a user-registered Ns_ServerRootProc. + */ + + path = (servPtr->vhost.serverRootProc)(dest, host, servPtr->vhost.serverRootArg); + if (path == NULL) { + goto defpath; + } + + } else if (servPtr->vhost.enabled + && (host != NULL + || ((conn = Ns_GetConn()) != NULL + && (headers = Ns_ConnHeaders(conn)) != NULL + && (host = Ns_SetIGet(headers, "Host")) != NULL)) + && *host != '\0') { + + /* + * Bail out if there are suspicious characters. + */ + + for (p = host; *p != '\0'; p++) { + if (isslash(*p) || isspace(*p) || (p[0] == '.' && p[1] == '.')) { + goto defpath; + } + } + host = Ns_StrToLower(host); + + path = Ns_MakePath(dest, servPtr->fastpath.serverdir, + servPtr->vhost.hostprefix, NULL); + + if (servPtr->vhost.opts & NSD_STRIP_WWW) { + if (strncmp(host, "www.", 4) == 0) { + host = &host[4]; + } + } + if (servPtr->vhost.opts & NSD_STRIP_PORT) { + if ((port = strrchr(host, ':')) != NULL) { + *port = '\0'; + } + } + + if (servPtr->vhost.hosthashlevel > 0) { + Ns_HashPath(dest, host, servPtr->vhost.hosthashlevel); + } + Ns_NormalizePath(dest, host); + + if (port != NULL) { + *port = ':'; + } + + } else { + + /* + * Default to static server root. + */ + + defpath: + path = Ns_MakePath(dest, servPtr->fastpath.serverdir, NULL); + } + + return path; + } Index: fastpath.c =================================================================== RCS file: /cvsroot/naviserver/naviserver/nsd/fastpath.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** fastpath.c 16 Feb 2005 08:39:42 -0000 1.1.1.1 --- fastpath.c 12 Apr 2005 06:21:23 -0000 1.2 *************** *** 147,150 **** --- 147,151 ---- * * Return path name of the server pages directory. + * Depreciated: Use Ns_PagePath() which is virtual host aware. * * Results: *************** *** 161,166 **** { NsServer *servPtr = NsGetServer(server); ! ! return servPtr->fastpath.pageroot; } --- 162,170 ---- { NsServer *servPtr = NsGetServer(server); ! ! if (servPtr != NULL) { ! return servPtr->fastpath.pageroot; ! } ! return NULL; } *************** *** 629,634 **** status = (*servPtr->fastpath.url2file)(dsPtr, servPtr->server, url); } else { ! Ns_MakePath(dsPtr, servPtr->fastpath.pageroot, url, NULL); ! status = NS_OK; } if (status == NS_OK) { --- 633,639 ---- status = (*servPtr->fastpath.url2file)(dsPtr, servPtr->server, url); } else { ! NsPageRoot(dsPtr, servPtr, NULL); ! Ns_MakePath(dsPtr, url, NULL); ! status = NS_OK; } if (status == NS_OK) { Index: server.c =================================================================== RCS file: /cvsroot/naviserver/naviserver/nsd/server.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** server.c 18 Mar 2005 08:21:06 -0000 1.2 --- server.c 12 Apr 2005 06:21:23 -0000 1.3 *************** *** 377,387 **** } } ! servPtr->fastpath.pageroot = Ns_ConfigGetValue(path, "pageroot"); ! if (servPtr->fastpath.pageroot == NULL) { ! servPtr->fastpath.pageroot = Ns_ConfigGetValue(spath, "pageroot"); ! if (servPtr->fastpath.pageroot == NULL) { ! Ns_ModulePath(&ds, server, NULL, "pages", NULL); ! servPtr->fastpath.pageroot = Ns_DStringExport(&ds); ! } } p = Ns_ConfigGetValue(path, "directorylisting"); --- 377,398 ---- } } ! servPtr->fastpath.serverdir = Ns_ConfigGetValue(path, "serverdir"); ! if (servPtr->fastpath.serverdir == NULL) { ! Ns_MakePath(&ds, Ns_InfoHomePath(), "servers", server, NULL); ! servPtr->fastpath.serverdir = Ns_DStringExport(&ds); ! } else if (!Ns_PathIsAbsolute(servPtr->fastpath.serverdir)) { ! Ns_MakePath(&ds, Ns_InfoHomePath(), servPtr->fastpath.serverdir, NULL); ! servPtr->fastpath.serverdir = Ns_DStringExport(&ds); ! } ! servPtr->fastpath.pagedir = Ns_ConfigGetValue(path, "pagedir"); ! if (servPtr->fastpath.pagedir == NULL) { ! servPtr->fastpath.pagedir = "pages"; ! } ! if (Ns_PathIsAbsolute(servPtr->fastpath.pagedir)) { ! servPtr->fastpath.pageroot = servPtr->fastpath.pagedir; ! } else { ! Ns_MakePath(&ds, servPtr->fastpath.serverdir, ! servPtr->fastpath.pagedir, NULL); ! servPtr->fastpath.pageroot = Ns_DStringExport(&ds); } p = Ns_ConfigGetValue(path, "directorylisting"); *************** *** 396,399 **** --- 407,444 ---- /* + * Initialize virtual hosting. + */ + + path = Ns_ConfigGetPath(server, NULL, "vhost", NULL); + Ns_ConfigGetBool(path, "enabled", &servPtr->vhost.enabled); + if (servPtr->vhost.enabled + && Ns_PathIsAbsolute(servPtr->fastpath.pagedir)) { + + Ns_Log(Error, "virtual hosting disabled, pagedir not relative: %s", + servPtr->fastpath.pagedir); + servPtr->vhost.enabled = NS_FALSE; + } + if (!Ns_ConfigGetBool(path, "stripwww", &i) || i) { + servPtr->vhost.opts |= NSD_STRIP_WWW; + } + if (!Ns_ConfigGetBool(path, "stripport", &i) || i) { + servPtr->vhost.opts |= NSD_STRIP_PORT; + } + servPtr->vhost.hostprefix = Ns_ConfigGetValue(path, "hostprefix"); + Ns_ConfigGetInt(path, "hosthashlevel", &servPtr->vhost.hosthashlevel); + if (servPtr->vhost.hosthashlevel < 0) { + servPtr->vhost.hosthashlevel = 0; + } + if (servPtr->vhost.hosthashlevel > 5) { + servPtr->vhost.hosthashlevel = 5; + } + if (servPtr->vhost.enabled) { + NsPageRoot(&ds, servPtr, ns_strdup("www.example.com:80")); + Ns_Log(Notice, "vhost[%s]: www.example.com:80 -> %s", + server, ds.string); + Ns_DStringTrunc(&ds, 0); + } + + /* * Configure the url, proxy and redirect requests. */ Index: tclcmds.c =================================================================== RCS file: /cvsroot/naviserver/naviserver/nsd/tclcmds.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** tclcmds.c 2 Apr 2005 20:31:59 -0000 1.8 --- tclcmds.c 12 Apr 2005 06:21:23 -0000 1.9 *************** *** 89,92 **** --- 89,93 ---- NsTclGmTimeObjCmd, NsTclGuessTypeObjCmd, + NsTclHashPathObjCmd, NsTclHTUUDecodeObjCmd, NsTclHTUUEncodeObjCmd, *************** *** 100,103 **** --- 101,105 ---- NsTclLinkObjCmd, NsTclLocalTimeObjCmd, + NsTclLocationProcObjCmd, NsTclLogObjCmd, NsTclLogCtlObjCmd, *************** *** 117,120 **** --- 119,123 ---- NsTclNsvSetObjCmd, NsTclNsvUnsetObjCmd, + NsTclPagePathObjCmd, NsTclParseArgsObjCmd, NsTclParseHttpTimeObjCmd, *************** *** 149,152 **** --- 152,157 ---- NsTclSemaObjCmd, NsTclServerObjCmd, + NsTclServerPathObjCmd, + NsTclServerRootProcObjCmd, NsTclSetCookieObjCmd, NsTclSetObjCmd, *************** *** 246,250 **** --- 251,262 ---- {"ns_info", NULL, NsTclInfoObjCmd}, + + {"ns_hashpath", NULL, NsTclHashPathObjCmd}, {"ns_modulepath", NULL, NsTclModulePathObjCmd}, + {"ns_pagepath", NULL, NsTclPagePathObjCmd}, + {"ns_serverpath", NULL, NsTclServerPathObjCmd}, + + {"ns_serverrootproc", NULL, NsTclServerRootProcObjCmd}, + {"ns_locationproc", NULL, NsTclLocationProcObjCmd}, /* Index: proc.c =================================================================== RCS file: /cvsroot/naviserver/naviserver/nsd/proc.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** proc.c 12 Apr 2005 05:09:42 -0000 1.4 --- proc.c 12 Apr 2005 06:21:23 -0000 1.5 *************** *** 63,67 **** static Tcl_HashTable info; ! struct proc { void *procAddr; char *desc; --- 63,67 ---- static Tcl_HashTable info; ! static struct proc { void *procAddr; char *desc; *************** *** 70,74 **** --- 70,76 ---- {(void *) NsTclThread, "ns:tclthread", NsTclThreadArgProc}, {(void *) Ns_TclCallbackProc, "ns:tclcallback", Ns_TclCallbackArgProc}, + {(void *) NsTclConnLocation, "ns:tclconnlocation", Ns_TclCallbackArgProc}, {(void *) NsTclSchedProc, "ns:tclschedproc", Ns_TclCallbackArgProc}, + {(void *) NsTclServerRoot, "ns:tclserverroot", Ns_TclCallbackArgProc}, {(void *) NsTclSockProc, "ns:tclsockcallback", NsTclSockArgProc}, {(void *) NsCachePurge, "ns:cachepurge", NsCacheArgProc}, Index: info.c =================================================================== RCS file: /cvsroot/naviserver/naviserver/nsd/info.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** info.c 28 Mar 2005 17:02:07 -0000 1.2 --- info.c 12 Apr 2005 06:21:23 -0000 1.3 *************** *** 673,677 **** Tcl_SetResult(interp, itPtr->servPtr->tcl.library, TCL_STATIC); } else { ! Tcl_SetResult(interp, itPtr->servPtr->fastpath.pageroot, TCL_STATIC); } } --- 673,678 ---- Tcl_SetResult(interp, itPtr->servPtr->tcl.library, TCL_STATIC); } else { ! NsPageRoot(&ds, itPtr->servPtr, NULL); ! Tcl_DStringResult(interp, &ds); } } |
From: Stephen D. <sd...@us...> - 2005-04-12 06:21:35
|
Update of /cvsroot/naviserver/naviserver/tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22726/tests Modified Files: test.nscfg Added Files: ns_conn_host.test ns_hashpath.test ns_pagepath.test ns_serverpath.test Log Message: * include/ns.h: * nsd/nsd.h: * nsd/info.c: * nsd/proc.c: * nsd/return.c: * nsd/server.c: * nsd/fastpath.c: * nsd/pathname.c: New concept: server root. Callback can be registered to create the server root, defaults to statically assigned 'serverroot' from config, or host-based if enabled. Many virtual hosting options added. (RFE #1159471) * nsd/conn.c: Add callback to generate current location. If none registered, uses host-header and falls back to driver's location. Add new Ns_ConnAppendLocation() as preferred method of access, depreciated Ns_ConnLocation(). * nsd/tclcmds.c: Add vhost related Tcl commands: ns_serverpath ns_pagepath ns_hashpath ns_serverrootproc ns_locationproc. * ns_pagepath.test: * ns_conn_host.test: * ns_serverpath.test: * ns_hashpath.test: * tests/test.nscfg: Add tests for vhost related commands. More location tests needed... --- NEW FILE: ns_conn_host.test --- # # $Header: /cvsroot/naviserver/naviserver/tests/ns_conn_host.test,v 1.1 2005/04/12 06:21:24 sdeasey Exp $ # package require tcltest 2.2 namespace import -force ::tcltest::* eval ::tcltest::configure $argv if {[ns_config test listenport]} { testConstraint serverListen true } set driverlocation http://[ns_config "ns/server/test/module/nssock" hostname] set self ${driverlocation}:[ns_config "ns/server/test/module/nssock" port] test ns_conn_location-1.1 {http 1.1 host} -constraints serverListen -setup { ns_eval {{ proc conn_location_request {args} { ns_return 200 text/plain [ns_conn location] } }} ns_register_proc GET /location conn_location_request } -body { set id [ns_http queue GET $self/location] ns_http wait $id location set location } -cleanup { ns_eval {{ rename conn_location_request {} }} ns_unregister_proc GET /location ns_http cleanup unset -nocomplain id location } -result $self unset -nocomplain driverhost self cleanupTests --- NEW FILE: ns_hashpath.test --- # # $Header: /cvsroot/naviserver/naviserver/tests/ns_hashpath.test,v 1.1 2005/04/12 06:21:24 sdeasey Exp $ # package require tcltest 2.2 namespace import -force ::tcltest::* eval ::tcltest::configure $argv test ns_hashpath-1.1 {basic syntax} -body { ns_hashpath } -returnCodes error -result {wrong # args: should be "ns_hashpath string levels"} test ns_hashpath-1.2 {basic syntax} -body { ns_hashpath "" 0 } -returnCodes error -result {levels must be an interger greater than zero} test ns_hashpath-1.3 {basic syntax} -body { ns_hashpath "" -1 } -returnCodes error -result {levels must be an interger greater than zero} test ns_hashpath-1.4 {basic syntax} -body { ns_hashpath "" notanum } -returnCodes error -result {levels must be an interger greater than zero} test ns_hashpath-2.1 {paths} -body { ns_hashpath x 1 } -result /x test ns_hashpath-2.2 {paths} -body { ns_hashpath xxx 1 } -result /x test ns_hashpath-2.3 {paths} -body { ns_hashpath xxx 2 } -result /x/x test ns_hashpath-2.4 {paths} -body { ns_hashpath xxx 3 } -result /x/x/x test ns_hashpath-3.1 {short paths} -body { ns_hashpath x 2 } -result /x/_ test ns_hashpath-3.1 {short paths} -body { ns_hashpath x 3 } -result /x/_/_ test ns_hashpath-3.1 {short paths} -body { ns_hashpath xx 3 } -result /x/x/_ cleanupTests --- NEW FILE: ns_serverpath.test --- # # $Header: /cvsroot/naviserver/naviserver/tests/ns_serverpath.test,v 1.1 2005/04/12 06:21:24 sdeasey Exp $ # package require tcltest 2.2 namespace import -force ::tcltest::* eval ::tcltest::configure $argv set serverroot [file join [ns_config "test" home] \ [ns_config "ns/server/test/fastpath" serverdir]] set vhosts [ns_config "ns/server/test/vhost" hostprefix] test ns_serverpath-1.1 {basic path} -body { ns_serverpath } -result $serverroot test ns_serverpath-1.2 {basic path} -body { ns_serverpath foo bar } -result ${serverroot}/foo/bar test ns_serverpath-1.3 {basic path} -body { ns_serverpath -- foo bar } -result ${serverroot}/foo/bar test ns_serverpath-2.1 {host path} -body { ns_serverpath -host example.com } -result ${serverroot}/${vhosts}/e/x/a/example.com test ns_serverpath-2.2 {host path} -body { ns_serverpath -host EXAMPLE.COM } -result ${serverroot}/${vhosts}/e/x/a/example.com test ns_serverpath-2.3 {host path} -body { ns_serverpath -host www.example.com } -result ${serverroot}/${vhosts}/e/x/a/example.com test ns_serverpath-2.4 {host path} -body { ns_serverpath -host www.example.com:80 } -result ${serverroot}/${vhosts}/e/x/a/example.com test ns_serverpath-2.5 {host path} -body { ns_serverpath -host 1 } -result ${serverroot}/${vhosts}/1/_/_/1 test ns_serverpath-2.6 {host path} -body { ns_serverpath -host "" } -result ${serverroot} test ns_serverpath-3.1 {bad host} -body { ns_serverpath -host " " } -result ${serverroot} test ns_serverpath-3.2 {bad host} -body { ns_serverpath -host / } -result ${serverroot} test ns_serverpath-3.3 {bad host} -body { ns_serverpath -host ../example.com } -result ${serverroot} test ns_serverpath-3.4 {bad host} -body { ns_serverpath -host www.example.com//naughty } -result ${serverroot} test ns_serverpath-3.5 {bad host} -body { ns_serverpath -host www.example.com/../naughty } -result ${serverroot} test ns_serverpath-3.6 {bad host} -body { ns_serverpath -host .. 2dots } -result ${serverroot}/2dots test ns_serverpath-3.6 {bad host} -body { ns_serverpath -host ... 3dots } -result ${serverroot}/3dots unset -nocomplain serverroot vhosts cleanupTests Index: test.nscfg =================================================================== RCS file: /cvsroot/naviserver/naviserver/tests/test.nscfg,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** test.nscfg 3 Apr 2005 06:38:01 -0000 1.1 --- test.nscfg 12 Apr 2005 06:21:24 -0000 1.2 *************** *** 1,10 **** # ! # ... # set servername test ns_section "ns/parameters" ! ns_param home ./tests ns_section "ns/servers" --- 1,37 ---- # ! # Configuration file for server to run tests in command mode. ! # ! # $Header$ # set servername test + + + # + # Parameters for test scripts. + # + + ns_section "test" + ns_param servername $servername + ns_param home [pwd]/tests + + for {set port 8000} {$port < 8100} {incr port} { + if {![catch { + close [ns_socklisten 127.0.0.1 $port] + } msg]} { + break + } + } + ns_param listenport [expr $port < 8100 ? $port : 0] + + + + # + # Test server configuration. + # + ns_section "ns/parameters" ! ns_param home [ns_config "test" home] ns_section "ns/servers" *************** *** 12,19 **** ns_section "ns/server/${servername}" - ns_param pageroot servers/server1/pages ns_param enabletclpages true ns_section "ns/server/${servername}/tcl" ns_param initfile ../nsd/init.tcl ns_param library ../tcl --- 39,66 ---- ns_section "ns/server/${servername}" ns_param enabletclpages true + ns_section "ns/server/${servername}/fastpath" + ns_param serverdir testserver + ns_param pagedir pages + + ns_section "ns/server/${servername}/vhost" + ns_param enabled true + ns_param hostprefix vhosts + ns_param hosthashlevel 3 + ns_param stripport yes + ns_param stripwww yes + ns_section "ns/server/${servername}/tcl" ns_param initfile ../nsd/init.tcl ns_param library ../tcl + + ns_section "ns/server/${servername}/module/nssock" + ns_param port [ns_config "test" listenport] + ns_param hostname localhost + ns_param address 127.0.0.1 + + ns_section "ns/server/${servername}/modules" + if {[ns_config "test" listenport]} { + ns_param nssock [ns_config "test" home]/../nssock/nssock.so + } --- NEW FILE: ns_pagepath.test --- # # See: ns_serverpath.test for tests which thoroughly exercise the -host switch. # # $Header: /cvsroot/naviserver/naviserver/tests/ns_pagepath.test,v 1.1 2005/04/12 06:21:24 sdeasey Exp $ # package require tcltest 2.2 namespace import -force ::tcltest::* eval ::tcltest::configure $argv set serverroot [file join [ns_config "test" home] \ [ns_config "ns/server/test/fastpath" serverdir] ] set pagedir [ns_config "ns/server/test/fastpath" pagedir] set vhosts [ns_config "ns/server/test/vhost" hostprefix] test ns_pagepath-1.1 {basic path} -body { ns_pagepath } -result ${serverroot}/${pagedir} test ns_pagepath-1.2 {basic path} -body { ns_pagepath x y } -result ${serverroot}/${pagedir}/x/y test ns_pagepath-1.3 {basic path} -body { ns_pagepath -- x y } -result ${serverroot}/${pagedir}/x/y test ns_pagepath-2.1 {host path} -body { ns_pagepath -host www.example.com } -result ${serverroot}/${vhosts}/e/x/a/example.com/${pagedir} test ns_pagepath-2.2 {host path} -body { ns_pagepath -host www.example.com -- } -result ${serverroot}/${vhosts}/e/x/a/example.com/${pagedir} test ns_pagepath-2.3 {host path} -body { ns_pagepath -host www.example.com -- x } -result ${serverroot}/${vhosts}/e/x/a/example.com/${pagedir}/x test ns_pagepath-2.4 {host path} -body { ns_pagepath -host www.example.com x y } -result ${serverroot}/${vhosts}/e/x/a/example.com/${pagedir}/x/y unset -nocomplain serverroot pagedir vhosts cleanupTests |
From: Stephen D. <sd...@us...> - 2005-04-12 06:21:31
|
Update of /cvsroot/naviserver/naviserver/include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22726/include Modified Files: ns.h Log Message: * include/ns.h: * nsd/nsd.h: * nsd/info.c: * nsd/proc.c: * nsd/return.c: * nsd/server.c: * nsd/fastpath.c: * nsd/pathname.c: New concept: server root. Callback can be registered to create the server root, defaults to statically assigned 'serverroot' from config, or host-based if enabled. Many virtual hosting options added. (RFE #1159471) * nsd/conn.c: Add callback to generate current location. If none registered, uses host-header and falls back to driver's location. Add new Ns_ConnAppendLocation() as preferred method of access, depreciated Ns_ConnLocation(). * nsd/tclcmds.c: Add vhost related Tcl commands: ns_serverpath ns_pagepath ns_hashpath ns_serverrootproc ns_locationproc. * ns_pagepath.test: * ns_conn_host.test: * ns_serverpath.test: * ns_hashpath.test: * tests/test.nscfg: Add tests for vhost related commands. More location tests needed... Index: ns.h =================================================================== RCS file: /cvsroot/naviserver/naviserver/include/ns.h,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** ns.h 26 Mar 2005 17:42:26 -0000 1.13 --- ns.h 12 Apr 2005 06:21:22 -0000 1.14 *************** *** 483,487 **** typedef int (Ns_FilterProc) (void *arg, Ns_Conn *conn, int why); typedef int (Ns_UrlToFileProc) (Ns_DString *dsPtr, char *server, char *url); ! typedef char *(Ns_LocationProc) (Ns_Conn *conn); /* --- 483,489 ---- typedef int (Ns_FilterProc) (void *arg, Ns_Conn *conn, int why); typedef int (Ns_UrlToFileProc) (Ns_DString *dsPtr, char *server, char *url); ! typedef char *(Ns_ServerRootProc) (Ns_DString *dest, char *host, void *arg); ! typedef char *(Ns_ConnLocationProc) (Ns_Conn *conn, Ns_DString *dest, void *arg); ! typedef char *(Ns_LocationProc) (Ns_Conn *conn); /* depreciated */ /* *************** *** 516,521 **** NS_EXTERN void Ns_SetRequestAuthorizeProc(char *server, Ns_RequestAuthorizeProc *procPtr); - NS_EXTERN void Ns_SetLocationProc(char *server, Ns_LocationProc *procPtr); - NS_EXTERN void Ns_SetConnLocationProc(Ns_LocationProc *procPtr); NS_EXTERN void Ns_SetUserAuthorizeProc(Ns_UserAuthorizeProc *procPtr); NS_EXTERN int Ns_AuthorizeUser(char *user, char *passwd); --- 518,521 ---- *************** *** 647,650 **** --- 647,651 ---- NS_EXTERN int Ns_ConnPeerPort(Ns_Conn *conn); NS_EXTERN char *Ns_ConnLocation(Ns_Conn *conn); + NS_EXTERN char *Ns_ConnLocationAppend(Ns_Conn *conn, Ns_DString *dest); NS_EXTERN char *Ns_ConnHost(Ns_Conn *conn); NS_EXTERN int Ns_ConnPort(Ns_Conn *conn); *************** *** 655,658 **** --- 656,661 ---- NS_EXTERN void Ns_ConnSetWriteEncodedFlag(Ns_Conn *conn, int flag); NS_EXTERN void Ns_ConnSetUrlEncoding(Ns_Conn *conn, Tcl_Encoding encoding); + NS_EXTERN int Ns_SetConnLocationProc(Ns_ConnLocationProc *proc, void *arg); + NS_EXTERN void Ns_SetLocationProc(char *server, Ns_LocationProc *proc); /* depreciated */ /* *************** *** 968,974 **** --- 971,981 ---- NS_EXTERN char *Ns_NormalizePath(Ns_DString *dsPtr, char *path); NS_EXTERN char *Ns_MakePath(Ns_DString *dsPtr, ...); + NS_EXTERN char *Ns_HashPath(Ns_DString *dsPtr, char *string, int levels); NS_EXTERN char *Ns_LibPath(Ns_DString *dsPtr, ...); NS_EXTERN char *Ns_HomePath(Ns_DString *dsPtr, ...); NS_EXTERN char *Ns_ModulePath(Ns_DString *dsPtr, char *server, char *module, ...); + NS_EXTERN char *Ns_ServerPath(Ns_DString *dest, char *server, ...); + NS_EXTERN char *Ns_PagePath(Ns_DString *dest, char *server, ...); + NS_EXTERN int Ns_SetServerRootProc(Ns_ServerRootProc *proc, void *arg); /* |
From: Stephen D. <sd...@us...> - 2005-04-12 06:21:31
|
Update of /cvsroot/naviserver/naviserver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22726 Modified Files: ChangeLog Log Message: * include/ns.h: * nsd/nsd.h: * nsd/info.c: * nsd/proc.c: * nsd/return.c: * nsd/server.c: * nsd/fastpath.c: * nsd/pathname.c: New concept: server root. Callback can be registered to create the server root, defaults to statically assigned 'serverroot' from config, or host-based if enabled. Many virtual hosting options added. (RFE #1159471) * nsd/conn.c: Add callback to generate current location. If none registered, uses host-header and falls back to driver's location. Add new Ns_ConnAppendLocation() as preferred method of access, depreciated Ns_ConnLocation(). * nsd/tclcmds.c: Add vhost related Tcl commands: ns_serverpath ns_pagepath ns_hashpath ns_serverrootproc ns_locationproc. * ns_pagepath.test: * ns_conn_host.test: * ns_serverpath.test: * ns_hashpath.test: * tests/test.nscfg: Add tests for vhost related commands. More location tests needed... Index: ChangeLog =================================================================== RCS file: /cvsroot/naviserver/naviserver/ChangeLog,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** ChangeLog 12 Apr 2005 05:09:42 -0000 1.44 --- ChangeLog 12 Apr 2005 06:21:22 -0000 1.45 *************** *** 1,4 **** --- 1,28 ---- 2005-04-11 Stephen Deasey <sd...@us...> + * include/ns.h: + * nsd/nsd.h: + * nsd/info.c: + * nsd/proc.c: + * nsd/return.c: + * nsd/server.c: + * nsd/fastpath.c: + * nsd/pathname.c: New concept: server root. Callback can be + registered to create the server root, defaults to statically + assigned 'serverroot' from config, or host-based if enabled. + Many virtual hosting options added. (RFE #1159471) + * nsd/conn.c: Add callback to generate current location. If none + registered, uses host-header and falls back to driver's location. + Add new Ns_ConnAppendLocation() as preferred method of access, + depreciated Ns_ConnLocation(). + * nsd/tclcmds.c: Add vhost related Tcl commands: ns_serverpath + ns_pagepath ns_hashpath ns_serverrootproc ns_locationproc. + * ns_pagepath.test: + * ns_conn_host.test: + * ns_serverpath.test: + * ns_hashpath.test: + * tests/test.nscfg: Add tests for vhost related commands. More + location tests needed... + * nsd/proc.c: Add proc info for NsFastGet. Cleanup source code formatting. |
From: Stephen D. <sd...@us...> - 2005-04-12 05:09:54
|
Update of /cvsroot/naviserver/naviserver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20543 Modified Files: ChangeLog Log Message: Add proc info for NsFastGet. Cleanup source code formatting. Index: ChangeLog =================================================================== RCS file: /cvsroot/naviserver/naviserver/ChangeLog,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -d -r1.43 -r1.44 *** ChangeLog 12 Apr 2005 03:53:02 -0000 1.43 --- ChangeLog 12 Apr 2005 05:09:42 -0000 1.44 *************** *** 1,4 **** --- 1,7 ---- 2005-04-11 Stephen Deasey <sd...@us...> + * nsd/proc.c: Add proc info for NsFastGet. Cleanup source code + formatting. + * tests/ns_urlencode.test: Add missing tests for urlencode fix. |
From: Stephen D. <sd...@us...> - 2005-04-12 05:09:54
|
Update of /cvsroot/naviserver/naviserver/nsd In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20543/nsd Modified Files: proc.c Log Message: Add proc info for NsFastGet. Cleanup source code formatting. Index: proc.c =================================================================== RCS file: /cvsroot/naviserver/naviserver/nsd/proc.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** proc.c 26 Mar 2005 17:42:26 -0000 1.3 --- proc.c 12 Apr 2005 05:09:42 -0000 1.4 *************** *** 1,7 **** /* ! * 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" --- 1,7 ---- /* ! * The contents of this file are subject to the Mozilla 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://mozilla.org/. * * Software distributed under the License is distributed on an "AS IS" *************** *** 31,36 **** * proc.c -- * ! * Support for getting information on procs (thread routines, ! * callbacks, scheduled procs, etc.). */ --- 31,36 ---- * proc.c -- * ! * Support for describing procs and their arguments (thread routines, ! * callbacks, scheduled procs, etc.). */ *************** *** 39,42 **** --- 39,43 ---- #include "nsd.h" + /* * The following struct maintains callback and description for *************** *** 45,80 **** typedef struct Info { ! Ns_ArgProc *proc; ! char *desc; } Info; /* ! * The following struct array defines common procs in nsd. */ ! struct proc { ! void *procAddr; ! char *desc; ! Ns_ArgProc *argProc; ! } procs[] = { ! {(void *) NsTclThread, "ns:tclthread", NsTclThreadArgProc}, ! {(void *) Ns_TclCallbackProc, "ns:tclcallback", Ns_TclCallbackArgProc}, ! {(void *) NsTclSchedProc, "ns:tclschedproc", Ns_TclCallbackArgProc}, ! {(void *) NsTclSockProc, "ns:tclsockcallback", NsTclSockArgProc}, ! {(void *) NsCachePurge, "ns:cachepurge", NsCacheArgProc}, ! {(void *) NsConnThread, "ns:connthread", NsConnArgProc}, ! {(void *) NsTclFilter, "ns:tclfilter", Ns_TclCallbackArgProc}, ! {(void *) NsTclRequest, "ns:tclrequest", Ns_TclCallbackArgProc}, ! {(void *) NsAdpRequest, "ns:adprequest", Ns_StringArgProc}, ! {NULL, NULL, NULL} ! }; /* ! * Static functions defined in this file. */ - static void AppendAddr(Tcl_DString *dsPtr, char *prefix, void *addr); static Tcl_HashTable info; /* --- 46,84 ---- typedef struct Info { ! Ns_ArgProc *proc; ! char *desc; } Info; /* ! * Static functions defined in this file. */ ! static void ServerArgProc(Tcl_DString *dsPtr, void *arg); ! static void AppendAddr(Tcl_DString *dsPtr, char *prefix, void *addr); /* ! * Static variables defined in this file. */ static Tcl_HashTable info; + struct proc { + void *procAddr; + char *desc; + Ns_ArgProc *argProc; + } procs[] = { + {(void *) NsTclThread, "ns:tclthread", NsTclThreadArgProc}, + {(void *) Ns_TclCallbackProc, "ns:tclcallback", Ns_TclCallbackArgProc}, + {(void *) NsTclSchedProc, "ns:tclschedproc", Ns_TclCallbackArgProc}, + {(void *) NsTclSockProc, "ns:tclsockcallback", NsTclSockArgProc}, + {(void *) NsCachePurge, "ns:cachepurge", NsCacheArgProc}, + {(void *) NsConnThread, "ns:connthread", NsConnArgProc}, + {(void *) NsTclFilter, "ns:tclfilter", Ns_TclCallbackArgProc}, + {(void *) NsTclRequest, "ns:tclrequest", Ns_TclCallbackArgProc}, + {(void *) NsAdpRequest, "ns:adprequest", Ns_StringArgProc}, + {(void *) NsFastGet, "ns:fastget", ServerArgProc}, + {NULL, NULL, NULL} + }; + /* *************** *** 83,93 **** * NsInitProcInfo -- * ! * Initialize the proc info API and default compiled-in callbacks. * * Results: ! * None. * * Side effects: ! * None. * *---------------------------------------------------------------------- --- 87,97 ---- * NsInitProcInfo -- * ! * Initialize the proc info API and default compiled-in callbacks. * * Results: ! * None. * * Side effects: ! * None. * *---------------------------------------------------------------------- *************** *** 102,108 **** procPtr = procs; while (procPtr->procAddr != NULL) { ! Ns_RegisterProcInfo(procPtr->procAddr, procPtr->desc, ! procPtr->argProc); ! ++procPtr; } } --- 106,112 ---- procPtr = procs; while (procPtr->procAddr != NULL) { ! Ns_RegisterProcInfo(procPtr->procAddr, procPtr->desc, ! procPtr->argProc); ! ++procPtr; } } *************** *** 114,126 **** * Ns_RegisterProcInfo -- * ! * Register a callback to describe the arguments to a proc, ! * e.g., a thread start arg. * * Results: ! * None. * * Side effects: ! * Given argProc will be invoked for given procAddr by ! * Ns_GetProcInfo. * *---------------------------------------------------------------------- --- 118,130 ---- * Ns_RegisterProcInfo -- * ! * Register a proc description and a callback to describe the ! * arguments e.g., a thread start arg. * * Results: ! * None. * * Side effects: ! * Given argProc will be invoked for given procAddr by ! * Ns_GetProcInfo. * *---------------------------------------------------------------------- *************** *** 131,143 **** { Tcl_HashEntry *hPtr; ! Info *iPtr; ! int new; hPtr = Tcl_CreateHashEntry(&info, (char *) procAddr, &new); if (!new) { ! iPtr = Tcl_GetHashValue(hPtr); } else { ! iPtr = ns_malloc(sizeof(Info)); ! Tcl_SetHashValue(hPtr, iPtr); } iPtr->desc = desc; --- 135,147 ---- { Tcl_HashEntry *hPtr; ! Info *iPtr; ! int new; hPtr = Tcl_CreateHashEntry(&info, (char *) procAddr, &new); if (!new) { ! iPtr = Tcl_GetHashValue(hPtr); } else { ! iPtr = ns_malloc(sizeof(Info)); ! Tcl_SetHashValue(hPtr, iPtr); } iPtr->desc = desc; *************** *** 151,162 **** * Ns_GetProcInfo -- * ! * Format a string of information for the given proc ! * and arg, invoking the argProc callback if it exists. * * Results: ! * None. * * Side effects: ! * String will be appended to given dsPtr. * *---------------------------------------------------------------------- --- 155,166 ---- * Ns_GetProcInfo -- * ! * Format a string of information for the given proc ! * and arg, invoking the argProc callback if it exists. * * Results: ! * None. * * Side effects: ! * String will be appended to given dsPtr. * *---------------------------------------------------------------------- *************** *** 166,188 **** Ns_GetProcInfo(Tcl_DString *dsPtr, void *procAddr, void *arg) { ! Tcl_HashEntry *hPtr; ! Info *iPtr; ! static Info nullInfo = {NULL, NULL}; hPtr = Tcl_FindHashEntry(&info, (char *) procAddr); if (hPtr != NULL) { ! iPtr = Tcl_GetHashValue(hPtr); } else { ! iPtr = &nullInfo; } if (iPtr->desc != NULL) { ! Tcl_DStringAppendElement(dsPtr, iPtr->desc); } else { ! AppendAddr(dsPtr, "p", procAddr); } if (iPtr->proc != NULL) { ! (*iPtr->proc)(dsPtr, arg); } else { ! AppendAddr(dsPtr, "a", arg); } } --- 170,192 ---- Ns_GetProcInfo(Tcl_DString *dsPtr, void *procAddr, void *arg) { ! Tcl_HashEntry *hPtr; ! Info *iPtr; ! static Info nullInfo = {NULL, NULL}; hPtr = Tcl_FindHashEntry(&info, (char *) procAddr); if (hPtr != NULL) { ! iPtr = Tcl_GetHashValue(hPtr); } else { ! iPtr = &nullInfo; } if (iPtr->desc != NULL) { ! Tcl_DStringAppendElement(dsPtr, iPtr->desc); } else { ! AppendAddr(dsPtr, "p", procAddr); } if (iPtr->proc != NULL) { ! (*iPtr->proc)(dsPtr, arg); } else { ! AppendAddr(dsPtr, "a", arg); } } *************** *** 194,198 **** * Ns_StringArgProc -- * ! * Treat arg as cstring and copy to dstring. * * Results: --- 198,202 ---- * Ns_StringArgProc -- * ! * Info callback for procs which take a cstring arg. * * Results: *************** *** 217,229 **** *---------------------------------------------------------------------- * * AppendAddr -- * ! * Format a simple string with the given address. * * Results: ! * None. * * Side effects: ! * String will be appended to given dsPtr. * *---------------------------------------------------------------------- --- 221,258 ---- *---------------------------------------------------------------------- * + * ServerArgProc -- + * + * Info callback for procs which take an NsServer arg. + * + * Results: + * None. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + + void + ServerArgProc(Tcl_DString *dsPtr, void *arg) + { + NsServer *servPtr = arg; + + Tcl_DStringAppendElement(dsPtr, servPtr->server); + } + + + /* + *---------------------------------------------------------------------- + * * AppendAddr -- * ! * Format a simple string with the given address. * * Results: ! * None. * * Side effects: ! * String will be appended to given dsPtr. * *---------------------------------------------------------------------- *************** *** 233,243 **** AppendAddr(Tcl_DString *dsPtr, char *prefix, void *addr) { ! char buf[30]; ! ! if (addr == NULL) { ! sprintf(buf, "%s:0x0", prefix); ! } else { ! sprintf(buf, "%s:%p", prefix, addr); ! } ! Tcl_DStringAppendElement(dsPtr, buf); } --- 262,265 ---- AppendAddr(Tcl_DString *dsPtr, char *prefix, void *addr) { ! Ns_DStringPrintf(dsPtr, " %s:%p", prefix, addr); } |
From: Stephen D. <sd...@us...> - 2005-04-12 03:53:10
|
Update of /cvsroot/naviserver/naviserver/tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15023/tests Added Files: ns_urlencode.test Log Message: Add missing tests for urlencode fix. --- NEW FILE: ns_urlencode.test --- # # $Header: /cvsroot/naviserver/naviserver/tests/ns_urlencode.test,v 1.1 2005/04/12 03:53:02 sdeasey Exp $ # source harness.tcl load libnsd.so package require tcltest 2.2 namespace import -force ::tcltest::* test ns_urlencode-1.1 {Basic sanity checks} { # rfc2396 unreserved URI characters, except for + which receives # special treatment by the HTTP URL scheme. set unreserved "-.!~*'()0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" assertEquals "" [ns_urlencode ""] assertEquals "" [ns_urlencode -part path ""] assertEquals "" [ns_urlencode -part query ""] assertEquals "" [ns_urldecode ""] assertEquals "" [ns_urldecode -part path ""] assertEquals "" [ns_urldecode -part query ""] assertEquals $unreserved [ns_urlencode $unreserved] assertEquals $unreserved [ns_urldecode $unreserved] assertEquals "1/2/3" [ns_urlencode -part path 1 2 3] assertEquals "1&2&3" [ns_urlencode -part query 1 2 3] assertEquals "1&2&3" [ns_urlencode 1 2 3] assertEquals "1" [ns_urldecode "1"] assertEquals "1" [ns_urldecode -part path "1"] assertEquals "1" [ns_urldecode -part query "1"] } {} test ns_urlencode-2.1 {Spaces and plus signs} { assertEquals "+" [ns_urlencode -part path +] assertEquals "%2b" [string tolower [ns_urlencode -part query +]] assertEquals "%2b" [string tolower [ns_urlencode +]] assertEquals "%20" [ns_urlencode -part path " "] assertEquals "+" [ns_urlencode -part query " "] assertEquals "+" [ns_urlencode " "] assertEquals "+" [ns_urldecode -part path +] assertEquals " " [ns_urldecode -part query +] assertEquals " " [ns_urldecode +] assertEquals " " [ns_urldecode -part path " "] assertEquals " " [ns_urldecode -part query " "] assertEquals " " [ns_urldecode " "] assertEquals " " [ns_urldecode -part path "%20"] assertEquals " " [ns_urldecode -part query "%20"] assertEquals " " [ns_urldecode "%20"] assertEquals "+" [ns_urldecode -part path "%2b"] assertEquals "+" [ns_urldecode -part query "%2b"] assertEquals "+" [ns_urldecode "%2b"] assertEquals "+" [ns_urldecode "%2B"] } {} test ns_urlencode-3.1 {rfc2396 section 2.4.3 URI 'delim' characters} { assertEquals "%3c" [string tolower [ns_urlencode -part path "<"]] assertEquals "%3e" [string tolower [ns_urlencode -part path ">"]] assertEquals "%23" [string tolower [ns_urlencode -part path "\#"]] assertEquals "%25" [string tolower [ns_urlencode -part path "%"]] assertEquals "%22" [string tolower [ns_urlencode -part path "\""]] } {} test ns_urlencode-4.1 {rfc2396 section 2.4.3 URI 'unwise' characters} { assertEquals "%7b" [string tolower [ns_urlencode -part path "{"]] assertEquals "%7d" [string tolower [ns_urlencode -part path "}"]] assertEquals "%7c" [string tolower [ns_urlencode -part path "|"]] assertEquals "%5c" [string tolower [ns_urlencode -part path "\\"]] assertEquals "%5e" [string tolower [ns_urlencode -part path "^"]] assertEquals "%5b" [string tolower [ns_urlencode -part path "\["]] assertEquals "%5d" [string tolower [ns_urlencode -part path "\]"]] assertEquals "%60" [string tolower [ns_urlencode -part path "`"]] } {} test ns_urlencode-5.1 {rfc2396 section 3.3 URI path component reserved characters} { assertEquals "%2f" [string tolower [ns_urlencode -part path "/"]] assertEquals "%3f" [string tolower [ns_urlencode -part path "?"]] assertEquals "%3b" [string tolower [ns_urlencode -part path ";"]] assertEquals "%3d" [string tolower [ns_urlencode -part path "="]] assertEquals ":" [ns_urlencode -part path ":"] assertEquals "@" [ns_urlencode -part path "@"] assertEquals "&" [ns_urlencode -part path "&"] assertEquals "+" [ns_urlencode -part path "+"] assertEquals "$" [ns_urlencode -part path "$"] assertEquals "," [ns_urlencode -part path ","] } {} test ns_urlencode-6.1 {rfc2396 section 3.4 URI query component reserved characters} { assertEquals "%3b" [string tolower [ns_urlencode -part query ";"]] assertEquals "%2f" [string tolower [ns_urlencode -part query "/"]] assertEquals "%3f" [string tolower [ns_urlencode -part query "?"]] assertEquals "%3a" [string tolower [ns_urlencode -part query ":"]] assertEquals "%40" [string tolower [ns_urlencode -part query "@"]] assertEquals "%26" [string tolower [ns_urlencode -part query "&"]] assertEquals "%3d" [string tolower [ns_urlencode -part query "="]] assertEquals "%2b" [string tolower [ns_urlencode -part query "+"]] assertEquals "%2c" [string tolower [ns_urlencode -part query ","]] assertEquals "%24" [string tolower [ns_urlencode -part query "$"]] } {} cleanupTests |