Emmabuntus, Ubuntu, Derivate, Linux, Open Source BackTrack, Linux, distributions, Ubuntu, derivate, securuty, forensic VirtualBox, Linux, Ubuntu, Raring Ringtail synaptic, Ubuntu, Linux, software packages jwplayer, multimedia, Linux, Ubuntu, flash Meshlab, graphic, software, Ubuntu, open source, Linux Synapse, Linux, Ubuntu, raring, Quantal Gimp, Ubuntu, Linux FreeMind, Linux, open source Linux, infographic, history

rApache Web Application Development with R and Apache: Difference in r-handler and r-script (Chapter IV).

The latest Apache2 debian packages cause the web server to run in a very reduced environment, thus one is unable to set LD_LIBRARY_PATH before calling /etc/init.d/apache2. One option is to actually edit that file and add the LD_LIBRARY_PATH explicitly. Another is to use the apache2ctl scripts which are also bundled with the debian packages. Or you can add it to /etc/ld.so.conf.

4.6 sendBin.

Sends binary data to the browser. This function is equivalent to R's writeBin() function, but the connection argument is ignored. See the documentation to writeBin() in your R distribution for more information.





    object An R object to be written to the connection.
    con Ignored, and can be omitted from the call.
    size integer. The number of bytes per element in the byte stream. The default, NA_integer_, uses the natural size. Size changing is not supported for raw and complex vectors.
    endian The endian-ness ("big" or "little" of the target system for the file. Using "swap" will force swapping endian-ness.




4.7 receiveBin.

Reads data from the HTTP request body, if any. Returns a length zero raw vector when there's no more data to read.



4.8 setStatus.

Allows handlers to set the HTTP Status code for the response.



    status integer.


    logical vector. TRUE if successsfull, FALSE on failure.


5. rApache Variables.

In previous releases of rApache, information from the web server was passed to R handlers in a single variable. This system design element was copied from other apache modules, but it has proven to be too cumbersome to support in software maintenance. Rather, because R has support for lexical scoping and in a far broader sense the ability to manipulate the language, a simpler approach was implemented.

rApache variables, named similar to PHP variables, are read-only list variables whose values are in most cases character vectors. They are injected into the environment of the R handler, and they are found by your R code via lexical scoping rules.


5.1 GET.

The GET variable contains those values obtained from an HTTP GET method, i.e. the key-value pairs found after the "?" of an URL, or data passed from an HTTP form when the method attribute is "GET". For example, the following form:

<form method="GET" action="http://example.com/brew/get.html">
    <input type="text" name="p1" value="0.95">
    <input type="text" name="p2" value="0.7">
<input type="submit" name="Submit">

produces the following GET list variable:

> str(GET)
List of 3
$ p1    : chr "0.95"
$ p2    : chr "0.7"
$ Submit: chr "Submit Query"


5.2 POST.

The POST variable contains those values obtained from an HTTP POST method, i.e. data passed from an HTTP form when the method attribute is "POST". Switching the method to "POST" in the example form from the previous section will produce the same values, yet in the POST variable:

> str(POST)
List of 3
$ p1    : chr "0.95"
$ p2    : chr "0.7"
$ Submit: chr "Submit Query"



The COOKIES variable contains those values obtained from the HTTP response header named "Cookie". It is a list variable whose values are character vectors. See the setCookie function and this link for more info.

5.4 FILES.

The FILES variable contains information about uploaded files via HTTP forms when the enctype attribute is set to "multipart/form-data". The following form:

<form enctype="multipart/form-data" method="POST" action="URL">
    <input type="file" name="FirstFile">
    <input type="file" name="SecondFile">
<input type="submit" name="Upload">

produces this FILES variable:

> str(FILES)
List of 2
$ FirstFile :List of 2
  ..$ name    : chr "useR2007poster.pdf"
  ..$ tmp_name: chr "/tmp/apreqc9GlXE"
$ SecondFile:List of 2
  ..$ name    : chr "rapache-1.0.0-useR2007.tar.gz"
  ..$ tmp_name: chr "/tmp/apreqoQ2hhX"

If you liked this article, subscribe to the feed by clicking the image below to keep informed about new contents of the blog:


Share on Google Plus

About Hugo Repetto

Ubuntu is a Linux distribution that offers an operating system predominantly focused on desktop computers but also provides support for servers. Based on Debian GNU / Linux, Ubuntu focuses on ease of use, freedom in usage restriction, regular releases (every 6 months) and ease of installation.
    Blogger Comment
    Facebook Comment


Post a Comment