diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-10-20 00:37:24 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-10-20 00:37:24 -0700 |
commit | d059fe743df6a5e8a72fc1418f2c3ba1ed5ac1e6 (patch) | |
tree | a532d18a9993d429dfdcba2b87bc9e8897a8a6c2 /html/http-server.mu.html | |
parent | f24eeaab13d12b87bb219cb42861c5fe7d091053 (diff) | |
download | mu-d059fe743df6a5e8a72fc1418f2c3ba1ed5ac1e6.tar.gz |
3524
Diffstat (limited to 'html/http-server.mu.html')
-rw-r--r-- | html/http-server.mu.html | 39 |
1 files changed, 1 insertions, 38 deletions
diff --git a/html/http-server.mu.html b/html/http-server.mu.html index f3192ed5..d09f4f87 100644 --- a/html/http-server.mu.html +++ b/html/http-server.mu.html @@ -46,7 +46,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muControl">return-unless</span> socket session:num<span class="Special"> <- </span>$accept socket contents:&:source:char, sink:&:sink:char<span class="Special"> <- </span>new-channel <span class="Constant">30</span> - sink<span class="Special"> <- </span>start-running transmit-from-socket session, sink + sink<span class="Special"> <- </span>start-running receive-from-socket session, sink buf:&:buffer<span class="Special"> <- </span>new-buffer <span class="Constant">30</span> <span class="Delimiter">{</span> c:char, done?:bool, contents<span class="Special"> <- </span>read contents @@ -65,43 +65,6 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color $close-socket session $close-socket socket ] - -<span class="muRecipe">def</span> write-to-socket session-socket:num, s:text [ - <span class="Constant">local-scope</span> - <span class="Constant">load-ingredients</span> - len:num<span class="Special"> <- </span>length *s - i:num<span class="Special"> <- </span>copy <span class="Constant">0</span> - <span class="Delimiter">{</span> - done?:bool<span class="Special"> <- </span>greater-or-equal i, len - <span class="muControl">break-if</span> done? - c:char<span class="Special"> <- </span>index *s, i - $print <span class="Constant">[writing to socket: ]</span>, i, <span class="Constant">[ ]</span>, c, <span class="Constant">10/newline</span> - $write-to-socket session-socket, c - i<span class="Special"> <- </span>add i, <span class="Constant">1</span> - <span class="muControl">loop</span> - <span class="Delimiter">}</span> -] - -<span class="muRecipe">def</span> transmit-from-socket session:num, sink:&:sink:char<span class="muRecipe"> -> </span>sink:&:sink:char [ - <span class="Constant">local-scope</span> - <span class="Constant">load-ingredients</span> - <span class="Delimiter">{</span> - req:text, bytes-read:num<span class="Special"> <- </span>$read-from-socket session, <span class="Constant">4096/bytes</span> - $print <span class="Constant">[read ]</span>, bytes-read, <span class="Constant">[ bytes from socket]</span>, <span class="Constant">10/newline</span> - i:num<span class="Special"> <- </span>copy <span class="Constant">0</span> - <span class="Delimiter">{</span> - done?:bool<span class="Special"> <- </span>greater-or-equal i, bytes-read - <span class="muControl">break-if</span> done? - c:char<span class="Special"> <- </span>index *req, i - end-of-request?:bool<span class="Special"> <- </span>equal c, <span class="Constant">10/newline</span> - <span class="muControl">break-if</span> end-of-request? <span class="Comment"># To be safe, for now.</span> - sink<span class="Special"> <- </span>write sink, c - i<span class="Special"> <- </span>add i, <span class="Constant">1</span> - <span class="muControl">loop</span> - <span class="Delimiter">}</span> - <span class="Delimiter">}</span> - sink<span class="Special"> <- </span>close sink -] </pre> </body> </html> |