Mercurial > repos > rhope
comparison webserver.rhope @ 147:f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Mon, 22 Nov 2010 01:15:02 -0500 |
parents | 1f39e69446f9 |
children | f582fd6c75ee |
comparison
equal
deleted
inserted
replaced
146:1f39e69446f9 | 147:f3686f60985d |
---|---|
93 HTTP Not Found[client] | 93 HTTP Not Found[client] |
94 { | 94 { |
95 string <- "<html><head><title>Document Not Found</title></head><body>The document you requested is not available on this server.</body></html>" | 95 string <- "<html><head><title>Document Not Found</title></head><body>The document you requested is not available on this server.</body></html>" |
96 HTTP Response[client, Get Content Type[".html"], [string]Length, Dictionary[], "404 Not Found"] | 96 HTTP Response[client, Get Content Type[".html"], [string]Length, Dictionary[], "404 Not Found"] |
97 { | 97 { |
98 [string]Write to File[~] | 98 [[string]Write to File[~]]Close |
99 } | 99 } |
100 } | 100 } |
101 | 101 |
102 Good Path?[path:yep,nope] | 102 Good Path?[path:yep,nope] |
103 { | 103 { |
132 file <- Open[File[newpath],"r"] | 132 file <- Open[File[newpath],"r"] |
133 content length <- Length[file] | 133 content length <- Length[file] |
134 If[[content length] > [0]] | 134 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[file] } | 140 { Close[file] } |
140 }{ | 141 }{ |
141 HTTP Not Found[client] | 142 HTTP Not Found[client] |
142 } | 143 } |
143 }{ | 144 }{ |
159 | 160 |
160 } | 161 } |
161 | 162 |
162 Connection Start[con,address,handlers] | 163 Connection Start[con,address,handlers] |
163 { | 164 { |
165 Print["New connection!"] | |
164 ,client <- [con]Read Delim[["\r\n"]Buffer >>] | 166 ,client <- [con]Read Delim[["\r\n"]Buffer >>] |
165 { request <- String[~] } | 167 { request <- String[~] } |
166 parts <- [request]Split[" "] | 168 parts <- [request]Split[" "] |
167 Print[[[request]Append[" "]]Append[address]] | 169 Print[[[request]Append[" "]]Append[address]] |
168 [client]Read Delim[["\r\n\r\n"]Buffer >>] | 170 [client]Read Delim[["\r\n\r\n"]Buffer >>] |