Code Monkey home page Code Monkey logo

Comments (8)

jeffreyhorner avatar jeffreyhorner commented on June 5, 2024

Redirects work fine in rApache. Not sure what you're doing, but this works with rApache handlers like so:

# Apache conf
<Location /test/relocation>
        SetHandler r-handler
        RFileHandler @DOCROOT@/relocation.R::handler
</Location>
</code>

and R code:

# relocation.R
handler <- function(){
   loc <- '/index.html'
   if (!is.null(GET) && !is.null(GET$loc) && GET$loc != '')
      loc <- GET$loc
   setHeader("Location",loc)
  return(HTTP_MOVED_TEMPORARILY)
}

from rapache.

jeroen avatar jeroen commented on June 5, 2024

Hmz maybe it is because I am still using rapache 1.14. Whenever I use setHeader, the HTTP 200 is already sent as it seems.

from rapache.

jeroen avatar jeroen commented on June 5, 2024

I updated to rapache 1.18 can't get it to work. I created a file /var/www/R-files/test.rhtml with the following content:

cat("This is a test!");
setContentType(type='text/plain')
setHeader("Location", "http://www.google.com");
return(HTTP_MOVED_TEMPORARILY);

Then when I download it with curl, I see a HTTP 200 instead:

curl -i http://127.0.0.1/R-files/test.rhtml
HTTP/1.1 200 OK
Date: Fri, 06 Apr 2012 17:54:46 GMT
Server: Apache/2.2.20 (Ubuntu)
Location: http://www.google.com
Vary: Accept-Encoding
Transfer-Encoding: chunked
Content-Type: text/plain

This is a test!

from rapache.

jeffreyhorner avatar jeffreyhorner commented on June 5, 2024

Get rid of the cat statement and it will work. Not sure about that HTTP
spec but if you're going to redirect the user to another url then they will
never see the request body anyway.
On Apr 6, 2012 12:57 PM, "jeroenooms" <
[email protected]>
wrote:

I still can't get it to work. I created a file
/var/www/R-files/test.rhtml with the following content:

cat("This is a test!");
setContentType(type='text/plain')
setHeader("Location", "http://www.google.com");
return(HTTP_MOVED_TEMPORARILY);

Then when I download it with curl, I see a HTTP 200 instead:

curl -i http://127.0.0.1/R-files/test.rhtml
HTTP/1.1 200 OK
Date: Fri, 06 Apr 2012 17:54:46 GMT
Server: Apache/2.2.20 (Ubuntu)
Location: http://www.google.com
Vary: Accept-Encoding
Transfer-Encoding: chunked
Content-Type: text/plain

This is a test!


Reply to this email directly or view it on GitHub:
#3 (comment)

from rapache.

jeroen avatar jeroen commented on June 5, 2024

It doesn't work for me. Still get to see a HTTP 200, even without the text in the body.

from rapache.

jeffreyhorner avatar jeffreyhorner commented on June 5, 2024

What's your apache conf look like for this url?

On Mon, Apr 9, 2012 at 2:40 PM, jeroenooms
[email protected]
wrote:

It doesn't work for me. Still get to see a HTTP 200.


Reply to this email directly or view it on GitHub:
#3 (comment)

from rapache.

jeroen avatar jeroen commented on June 5, 2024

I just used my debugging config:

<Directory /var/www/R-files>
    SetHandler r-script
    RHandler sys.source
</Directory>

and then /var/www/R-files/test contains:

setHeader("Location", "http://www.google.com");
return(HTTP_MOVED_TEMPORARILY)

from rapache.

jeffreyhorner avatar jeffreyhorner commented on June 5, 2024

Okay, I've figured out why: sys.source returns invisible() which
essentially returns NULL to rApache. Therefore rApache will always
returns DONE.

Easiest thing to do is create your own handler.

Jeff

On Mon, Apr 9, 2012 at 2:50 PM, jeroenooms
[email protected]
wrote:

I just used my debugging config:

   <Directory /var/www/R-files>
       SetHandler r-script
       RHandler sys.source
   

and then /var/www/R-files/test contains:

   setHeader("Location", "http://www.google.com");
   return(HTTP_MOVED_TEMPORARILY)


Reply to this email directly or view it on GitHub:
#3 (comment)

from rapache.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.