Ghost header in response

18 views
Skip to first unread message

Nuno Maltez

unread,
Oct 10, 2013, 12:47:23 PM10/10/13
to rr...@googlegroups.com
Hi,

I've been playing with Rook and I noticed that it inserts a bad header line in the response whenever you provide a list with only one element to "headers", when building the response.

Using the "Hello" example from http://cran.r-project.org/web/packages/Rook/README.html

When I call the Rook app I get the following:

$ curl -v http://localhost:20430/custom/hello
* About to connect() to localhost port 20430 (#0)
*   Trying 127.0.0.1...
* connected
* Connected to localhost (127.0.0.1) port 20430 (#0)
> GET /custom/hello HTTP/1.1
> User-Agent: curl/7.27.0
> Host: localhost:20430
> Accept: */*
>
< HTTP/1.1 200 OK
< Content-type: text/html
< :
< Content-length: 42
<
* Connection #0 to host localhost left intact
<h1>Hello World! This is Rook 1.0-9 .</h1>* Closing connection #0


As you can see, there's a empty header between Content-type and Content-length (a line with just the ":"). To be honest, i would never have
noticed it it the Python requests library wouldn't choke on this response.

If I change the "headers" list to have 2 elements instead of one, adding a fake header:

headers = list(
        'Content-Type' = 'text/html',
        'X-FAKE-HEADER' = ''
        ),

I get rid of the bad header:

$ curl -v http://localhost:20430/custom/hello* About to connect() to localhost port 20430 (#0)
*   Trying 127.0.0.1...
* connected
* Connected to localhost (127.0.0.1) port 20430 (#0)
> GET /custom/hello HTTP/1.1
> User-Agent: curl/7.27.0
> Host: localhost:20430
> Accept: */*
>
< HTTP/1.1 200 OK
< Content-type: text/html
< X-FAKE-HEADER:
< Content-length: 42
<
* Connection #0 to host localhost left intact
<h1>Hello World! This is Rook 1.0-9 .</h1>* Closing connection #0


OK, I think python "requests" shouldn't just hang when this happens, but still that header line doesn't look right and might cause problems with other libraries...
Is this a known issue?

Thanks,
Nuno

Jeroen Ooms

unread,
Oct 10, 2013, 1:30:56 PM10/10/13
to rr...@googlegroups.com
The Rook package uses R's built-in "help server", which is known to have issues. The httpuv package provides an alternative implementation of Rook and it is much more reliable.

Alternatively look at some high-level packages like opencpu or shiny, which take care of all this low-level stuff so you don't have to worry about it at all.




--
You received this message because you are subscribed to the Google Groups "rRook" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rrook+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
0 new messages