Mercurial > repos > rhope
comparison framework.rhope @ 165:47ab97730865
Fix a couple of issues in networking lib
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Thu, 10 Mar 2011 04:15:37 +0000 |
parents | f582fd6c75ee |
children |
comparison
equal
deleted
inserted
replaced
161:f5095855c878 | 165:47ab97730865 |
---|---|
25 } | 25 } |
26 | 26 |
27 Framework Handler[con,path,request type,queryvars,headers,handler,title,use session] | 27 Framework Handler[con,path,request type,queryvars,headers,handler,title,use session] |
28 { | 28 { |
29 page <- Page[title, path, use session, queryvars, headers] | 29 page <- Page[title, path, use session, queryvars, headers] |
30 handler page <- [handler]Call[page,path] | 30 hstart <- time[0i64] |
31 { handler page <- [handler]Call[page,path] | |
32 { | |
33 hend <- time[0i64] | |
34 Print[["Handler took: "]Append[String[[hend]-[hstart]]]] | |
35 }} | |
31 If[[request type] = ["POST"]] | 36 If[[request type] = ["POST"]] |
32 { | 37 { |
33 final page,ncon <- Process POST[handler page, con, headers] | 38 final page,ncon <- Process POST[handler page, con, headers] |
34 }{ | 39 }{ |
35 final page <- Val[handler page] | 40 final page <- Val[handler page] |
36 ncon <- Val[con] | 41 ncon <- Val[con] |
37 } | 42 } |
38 string,out headers <- [final page]Render | 43 Val[final page] |
44 { rstart <- time[0i64] | |
45 { string,out headers <- [final page]Render | |
46 { | |
47 rend <- time[0i64] | |
48 Print[["Render took: "]Append[String[[rend]-[rstart]]]] | |
49 }}} | |
39 | 50 |
40 [[string]Write to File[HTTP OK[ncon, Get Content Type[".html"], [string]Byte Length, out headers]]]Close | 51 [[string]Write to File[HTTP OK[ncon, Get Content Type[".html"], [string]Byte Length, out headers]]]Close |
41 } | 52 } |
42 | 53 |
43 Handler Fixer[handler:out] | 54 Handler Fixer[handler:out] |
456 none <- text | 467 none <- text |
457 } | 468 } |
458 | 469 |
459 Escape HTML Text[string:out] | 470 Escape HTML Text[string:out] |
460 { | 471 { |
461 out <- [[[string]Replace["&","&"]]Replace["<", "<"]]Replace[">", ">"] | 472 out <- [string]Replace[("&","<",">"),("&","<",">")] |
462 } | 473 } |
463 | 474 |
464 Render@Web Text[text:out,headers] | 475 Render@Web Text[text:out,headers] |
465 { | 476 { |
466 escaped <- Escape HTML Text[[text]Text >>] | |
467 If[[text]Preformatted >>] | 477 If[[text]Preformatted >>] |
468 { | 478 { |
469 processed text <- Val[escaped] | 479 processed text <- Escape HTML Text[[text]Text >>] |
470 }{ | 480 }{ |
471 processed text <- [escaped]Replace["\n","<br>\n\t"] | 481 processed text <- [[text]Text >>]Replace[("&","<",">","\n"),("&","<",">","<br>\n\t")] |
472 } | 482 } |
473 If[[[[text]Enclosing Tag >>]Length] = [0]] | 483 If[[[[text]Enclosing Tag >>]Length] = [0]] |
474 { | 484 { |
475 out <- Val[processed text] | 485 out <- Val[processed text] |
476 }{ | 486 }{ |