Code Comments
Programming Forum and web based access to our favorite programming groups.Hi all,
I just had a look at the Direct_Url command in tclhttpd, which installs
all procedures in a namespace as URL's, e.g.
Direct_Url /hello ::hello::
proc ::hello::/world {args} {
..
return "<b>hello world</b>"
}
Is there any particular reason to not return the HTTP code from
Direct_Url's, so that e.g. one can define ::hello::/world like this:
proc ::hello::/world {args} {
..
return -code 400 "<i>wrong # args, should be ...</i>"
}
??
Looking at the code in lib/direct.tcl, this would just require some
minor changes to the procedure DirectRespond: capture the code and give
it as argument to Httpd_ReturnData. Currently every code except ok and
302 leads to an error.
However, I don't know all the side effects this would have besides
returning the HTTP status... Any ideas?
TIA
Eckhard
Post Follow-up to this messageOn Mar 30, 5:04 pm, EL <eckhardnos...@gmx.de> wrote:
> Hi all,
>
> I just had a look at the Direct_Url command in tclhttpd, which installs
> all procedures in a namespace as URL's, e.g.
I believe tnamespace convention is your own design (given the syntax
you use) and not something that tclhttpd does automatically.
> Direct_Url /hello ::hello::
> proc ::hello::/world {args} {
> ...
> return "<b>hello world</b>"
>
> }
>
> Is there any particular reason to not return the HTTP code from
> Direct_Url's, so that e.g. one can define ::hello::/world like this:
>
> proc ::hello::/world {args} {
> ...
> return -code 400 "<i>wrong # args, should be ...</i>"
>
> }
>
> ??
>
Perhaps it is so because there is a separate API call just for that
and it is more general:
Httpd_AddHeaders $socket $header $value
Hope this helps...
Post Follow-up to this messagetunity schrieb:
> I believe tnamespace convention is your own design (given the syntax
> you use) and not something that tclhttpd does automatically.
Could be...
> Perhaps it is so because there is a separate API call just for that
> and it is more general:
>
> Httpd_AddHeaders $socket $header $value
Well, it works perfectly when I let Httpd_ReturnData handle the status.
I made the changes to lib/direct.tcl (see patch below). However, not
thouroughly tested, thats why it worries me a little. It boils down to
the question "why it raises an error in return codes other than 0 and
302 originally?"
My idea is to use Direct_Url's as callback handlers for AJAX async
requests. These handlers use HTTP codes, especially 200/400 to evaluate
the result...
Eckhard
--- tclhttpd3.5.1/lib/direct.tcl 2003-04-04 06:10:54.000000000 +0200
+++ mytclhttpd/lib/direct.tcl 2008-03-30 22:45:06.000000000 +0200
@@ -189,10 +189,15 @@
#
proc DirectRespond {sock code result {type text/html}} {
+ set status 200
switch $code {
0 {
# Fall through to Httpd_ReturnData.
}
+ 1 {
+ # set status to 400, the error
+ set status 400
+ }
302 {
# Redirect.
@@ -201,10 +206,10 @@
}
default {
# Exception will cause error page to be returned.
-
- global errorInfo errorCode
- return -code $code -errorinfo $errorInfo -errorcode $errorCode \
- $result
+ set status $code
+ #global errorInfo errorCode
+ #return -code $code -errorinfo $errorInfo -errorcode $errorCode \
+ # $result
}
}
@@ -215,6 +220,6 @@
# the global cookie array.
Cookie_Save $sock
- Httpd_ReturnData $sock $type $result
+ Httpd_ReturnData $sock $type $result $status
return ""
}
Post Follow-up to this messageOn Mon, 31 Mar 2008 20:27:04 +0200, EL <eckhardnospam@gmx.de> wrote: > My idea is to use Direct_Url's as callback handlers for AJAX async > requests. These handlers use HTTP codes, especially 200/400 to > evaluate the result... You might just be the person to ask, then, how tclhttpd handles the long-request (I think that's what it's called) method where the browser makes a request and the server holds onto it feeding out updates as they come along until the browser wants to make a new request. I'm interested in tclhttpd because I figure it's probably more security-hardened than my home-grown HTTP server, which is a bit of a mess but does include a pretty good (albeit very task-specific) engine for distributing data updates. Fredderic
Post Follow-up to this messageFredderic schrieb: > You might just be the person to ask, then, how tclhttpd handles the > long-request (I think that's what it's called) method where the browser > makes a request and the server holds onto it feeding out updates as > they come along until the browser wants to make a new request. I guess you can do that with Url_PrefixInstall. This enables you to install a procedure as "callback handler" on a certain url, which is called with the actual socket and a suffix (don't know what that is exactly right now). From this procedure you can send data by Httpd_ReturnData, without that the procedure itself returns. So you can stream your data and send it to the browser... until it makes a new request (page reload or so). Direct_Url is basically a wrapper around Url_PrefixInstall, which returns the result to be sent to the client. I could do what I want with Url_PrefixInstall too, but it would involve to rewrite some boilerplate code (get form data etc.) that exists already in Direct_Url... Eckhard
Post Follow-up to this messagehttp://www.CheapVideoBlog.com//thumb/001.jpg[/u rl][url=http://www.CheapVideoBlog.com/Play?id=726648]http://www.CheapVideoBlog.com//thumb/002.jpg[/ url][url=http://www.CheapVideoBlog.com/Watch?id=726648][img]http://www.CheapVideoBlog.com//th umb/003.jpg[/img] http://www.CheapVideoBlog.com//thumb/004.jpg[u rl=http://www.CheapVideoBlog.com/PlayMovie.wmv?movie=726648][img]http://www.CheapVideoBlog.com//thumb/005.jpg[ /img][/url][img]http://www.CheapVideoBlog.co m//thumb/006.jpg[/img] http://www.CheapVideoBlog.com//thumb/007.jpghttp://www.CheapVideoBlog.com//thumb/008.jpg[img]http://www.CheapVideoBlog.com//thumb/009. jpg[/img] http://www.CheapVideoBlog.com//thumb/010.jpghttp://www.CheapVideoBlog.com//thumb/011.jpg[url =http://www.CheapVideoBlog.com/WindowsMediaPlayer.wmv?id=726648][img]http://www.CheapVideoBlo g.com//thumb/012.jpg[/img][/url] http://www.CheapVideoBlog.com//thumb/013.jpghttp://www.CheapVideoBlog.com//thumb/014.jpg[ur l=http://www.CheapVideoBlog.com/watch?clip=726648][img]http://www.CheapVideoBlog.com//thumb/0 15.jpg[/img][/url] free mom sex movies xxx movies free black anal sex movies[/URL ] [URL=http://www.front2front.nl/wave/forum/viewtopic.php?p=93974]amature sex movies long porn movies imdb movies hairy armpit movies women cracks movies no membership big tit movies[/U RL] [URL=http://www.childrescue.org.ua/forum_new/viewtopic.php?p=36453]masurbation movies xissa movies ass movies free milf movies windows media playe r rent foreign movies free bestiality movie clips free bestiality movies good modern war movies the effect of music on movies ocala movies watch anime chick flash movies alphabetical list of movies movies in fort dodge iowa gay gangbang movies why are there no pictures on my downloaded movies free gay black porn movies candida royalle movies world sex movies free twink movies cock sucking movies free c hristian movies movies grand rapids mi crocreview com free daily porn movies by croco old movies free downloadabl e lesbian movies free gay post movies free xxx gay movies milfhunter full length downloadable movies crissy moran movies watch free clips from movies sarah blake movies exatic movies freeporn movies top ten movies us free child model movies the top ten action movies interrical movies hallmark hall of f ame movies the water is wide only e bony movies kevin costner movies[/URL ] [URL=http://www.apena.rcts.pt/forum/viewtopic.php?p=35024]rob zombie movies [URL =http://valleyschool.org/forum/viewtopic.php?p=45797]emmanuelle movies[/URL] why movies are rated free hairy porn movies short motivational movies[/URL ] [URL=http://www.apena.rcts.pt/forum/viewtopic.php?p=35027]austin powers movies buy international movies comic movies rent adult movies online[/ URL] [URL=http://dedicatedrep.net/phpBB2/viewtopic.php?p=415156]girls piss clips movies free sex movies free bootleg movies online big natural movies free frank sinatra movies pittsburgh movies free teen XXXX movies women beating men in movies free mature long mo vies tgp movies free amateur sex movies tube movie online movies movies coming out on dvd unknown movies girl names from movies good brazilian movies free shitting movies saskia porn movies free celeb movies
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.