The R Project SVN R

Rev

Rev 86511 | Rev 86790 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 86511 Rev 86514
Line 18... Line 18...
18
 */
18
 */
19
 
19
 
20
/* This is a small HTTP server that serves requests by evaluating
20
/* This is a small HTTP server that serves requests by evaluating
21
 * the httpd() function and passing the result to the browser. */
21
 * the httpd() function and passing the result to the browser. */
22
 
22
 
-
 
23
/* Note that the server runs partially on the main R thread (it has to,
-
 
24
   because it uses R), and it also sends the response mostly from the
-
 
25
   main thread. It is thus not possible to use the server from the R thread
-
 
26
   itself, e.g. via download.file(), because of a deadlock between the
-
 
27
   server and the client, when the data isn't sent in a single chunk.
-
 
28
   On Unix, the deadlock could also happen when the client is sending a
-
 
29
   request to the server (and the request isn't sent in a single chunk).
-
 
30
 
-
 
31
   This cannot happen with the intended use of this server, when it is used
-
 
32
   to serve help pages to an external client (a web browser).
-
 
33
*/
-
 
34
 
23
/* Example:
35
/* Example:
24
   httpd <- function(path,query=NULL,...) {
36
   httpd <- function(path,query=NULL,...) {
25
      cat("Request for:", path,"\n"); print(query);
37
      cat("Request for:", path,"\n"); print(query);
26
      list(paste("Hello, <b>world</b>!<p>You asked for \"",path,"\".",sep=''))
38
      list(paste("Hello, <b>world</b>!<p>You asked for \"",path,"\".",sep=''))
27
   }
39
   }