Re: Tclhttpd: why not return the HTTP status from Direct_Url?



tunity 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 ""
}
.



Relevant Pages

  • Re: Merge all files in a folder
    ... Thank for your assistance, your codes works excellently. ... another workbook, named "OLT" to a new sheet here. ... Another request is the the current macro will filter as: ... move it to start at A2 and name the Header column as Securities since the ...
    (microsoft.public.excel.programming)
  • Re: huffman header compression
    ... So far I think Elias gamma coding is the best method I've come up with, ... Uncompressed Header in bits.. ... and huffman codes the result. ... so this is a perfect example of a bijection between long and short ...
    (comp.compression)
  • Re: combining workspaces
    ... have same variables (in their declaration in header). ... their headers and in .C in B's workspace (which is a HERCULIAN ... considering the voluminosity of the codes). ... You just discovered why it's a good idea not to use file scope ...
    (comp.lang.c)
  • Re: Page Numbering is not right
    ... View | Header and Footer. ... Press Alt+F9 to show field codes; ... Microsoft Word MVP ...
    (microsoft.public.word.pagelayout)
  • Re: huffman header compression
    ... code-lengths) have the shortest codes. ... overhead of using a single marker in the header witch is a one off ... bijection of Elias gamma codes longest to shortest... ... but also we have to somehow encode lengths of zero.. ...
    (comp.compression)