Mercurial > repos > rhope
comparison webserver.rhope @ 149:804e48af1027
Fix file not found handling
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Mon, 22 Nov 2010 20:38:03 +0000 |
parents | f582fd6c75ee |
children | 47ab97730865 |
comparison
equal
deleted
inserted
replaced
148:f582fd6c75ee | 149:804e48af1027 |
---|---|
127 the handler <- [handler]Index[handlerpath] {} | 127 the handler <- [handler]Index[handlerpath] {} |
128 { | 128 { |
129 ,newpath <- [path]Slice[1] | 129 ,newpath <- [path]Slice[1] |
130 Good Path?[newpath] | 130 Good Path?[newpath] |
131 { | 131 { |
132 file <- Open[File[newpath],"r"] | 132 file,bad file <- Open[File[newpath],"r"] |
133 content length <- Length[file] | 133 content length <- Length[file] |
134 If[[content length] > [0]] | 134 ,bad file <- If[[content length] > [0]] |
135 { | 135 { |
136 data <- [file]Read[content length] | 136 data <- [file]Read[content length] |
137 [[HTTP OK[client, Get Content Type[path], content length, Dictionary[]] | 137 [[HTTP OK[client, Get Content Type[path], content length, Dictionary[]] |
138 ]Write[data] | 138 ]Write[data] |
139 ]Close | 139 ]Close |
140 { Close[file] } | 140 { Close[file] } |
141 }{ | 141 } |
142 Val[bad file] | |
143 { | |
142 HTTP Not Found[client] | 144 HTTP Not Found[client] |
143 } | 145 } |
144 }{ | 146 }{ |
145 HTTP Not Found[client] | 147 HTTP Not Found[client] |
146 } | 148 } |