version 1.14, 2009/02/22 17:30:03 |
version 1.17, 2013/03/07 02:10:32 |
|
|
%% $OpenXM: OpenXM/src/kan96xx/Doc/httpd-rpc.sm1,v 1.13 2002/12/04 00:02:10 takayama Exp $ |
%% $OpenXM: OpenXM/src/kan96xx/Doc/httpd-rpc.sm1,v 1.16 2012/12/23 02:33:16 takayama Exp $ |
%% http server by sm1. Used for RPC. Generic example. |
%% http server by sm1. Used for RPC. Generic example. |
|
|
[(parse) (httpd.sm1) pushfile] extension pop |
[(parse) (httpd.sm1) pushfile] extension pop |
|
/httpd.textmode 1 def %% It does not work on some browsers. |
|
|
/httpd_action { |
/httpd_action { |
httpd_action_allow_file_transfer |
httpd_action_allow_file_transfer |
|
|
3] extension |
3] extension |
}{ |
}{ |
%% On unix. |
%% On unix. |
[(sleep 3 ; netscape http://) |
[(ostype)] extension 1 get (mac) eq { |
|
/webrpc.browser (open) def |
|
} { /webrpc.browser (firefox) def } ifelse |
|
[(sleep 3 ; ) webrpc.browser ( http://) |
[(sm1.socket) (gethostname) []] extension |
[(sm1.socket) (gethostname) []] extension |
(:) httpd.port toString ( & ) ] cat |
(:) httpd.port toString ( & ) ] cat |
system |
system |
|
|
|
|
/send-page-result { |
/send-page-result { |
/arg1 set |
/arg1 set |
[/in-send-page-result /result] pushVariables |
[/in-send-page-result /result /hlen /msg1 /msg2] pushVariables |
[ |
[ |
/result arg1 def |
/result arg1 def |
|
/msg1 (<html> <body> <pre>) def |
|
/msg2 (</pre> </body> </html>) def |
|
httpd.textmode { 0 /hlen set } |
|
{ msg1 length msg2 length add 3 add /hlen set } ifelse |
(HTTP/0.9 200 OK) sendln |
(HTTP/0.9 200 OK) sendln |
(Connection: close) sendln |
(Connection: close) sendln |
[(Content-length: ) result length toString ] cat sendln |
[(Content-length: ) result length hlen add toString ] cat sendln |
(Content-Type: text/html) sendln |
httpd.textmode |
%(Content-Type: text/plain) sendln % It does not work on some browsers. |
{ (Content-Type: text/plain) sendln } % It does not work on some browsers. |
|
{ (Content-Type: text/html) sendln } ifelse |
0 sendln |
0 sendln |
|
|
(<html> <body> <pre>) sendln |
httpd.textmode { } { msg1 sendln } ifelse |
result sendln |
result sendln |
(</pre> </body> </html>) sendln |
httpd.textmode { } { msg2 sendln } ifelse |
0 sendln |
0 sendln |
[(flush)] extension |
[(flush)] extension |
] pop |
] pop |