Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
simple ruby proxy
Max Benjamin
11/25/2006 1:15:00 AM
Hello,
I'm trying to use a ruby program to grab html outside of my domain and
alter it for use in another page in my domain. This is a proxy, right?
I thought I wouldn't have a problem with this but... I do.
<%
require "cgi"
require "open-uri"
cgi = CGI.new()
url = cgi.params['myURL']
htmlDoc = ""
test = open(url)
test.each() do |line|
htmlDoc += line
end
%>
<%= htmlDoc %>
When I ask for this program in a GET request I'm asked if I want to save
the file rather than getting a display of the html. I'm sure this is
just some stupid noob mistake I'm making. Any help would be
appreciated.
Best,
Max
--
Posted via
http://www.ruby-...
.
3 Answers
Timothy Goddard
11/25/2006 2:35:00 AM
0
Max Benjamin wrote:
> Hello,
> I'm trying to use a ruby program to grab html outside of my domain and
> alter it for use in another page in my domain. This is a proxy, right?
> I thought I wouldn't have a problem with this but... I do.
> <%
> require "cgi"
> require "open-uri"
>
> cgi = CGI.new()
> url = cgi.params['myURL']
>
> htmlDoc = ""
> test = open(url)
> test.each() do |line|
> htmlDoc += line
> end
> %>
> <%= htmlDoc %>
> When I ask for this program in a GET request I'm asked if I want to save
> the file rather than getting a display of the html. I'm sure this is
> just some stupid noob mistake I'm making. Any help would be
> appreciated.
> Best,
> Max
>
> --
> Posted via
http://www.ruby-...
.
OpenURI can be used to open files. A script like this would be a major
security problem. The problem here with being asked to save it is that
you aren't sending the proper MIME type. Look at the CGI docs for how
to do this.
Max Benjamin
11/25/2006 3:42:00 AM
0
Timothy Goddard wrote:
> Max Benjamin wrote:
>>
>> appreciated.
>> Best,
>> Max
>>
>> --
>> Posted via
http://www.ruby-...
.
>
> OpenURI can be used to open files. A script like this would be a major
> security problem. The problem here with being asked to save it is that
> you aren't sending the proper MIME type. Look at the CGI docs for how
> to do this.
Ok, I'm still having some trouble getting this to work. I looked at the
cgi docs but find them a little daunting. Is there some example code
someone could point me to?
Thanks.
--
Posted via
http://www.ruby-...
.
KDr2
11/25/2006 5:38:00 AM
0
Max Benjamin <moore.joseph@gmail.com> writes:
> Timothy Goddard wrote:
>> Max Benjamin wrote:
>>>
>>> appreciated.
>>> Best,
>>> Max
>>>
>>> --
>>> Posted via
http://www.ruby-...
.
>>
>> OpenURI can be used to open files. A script like this would be a major
>> security problem. The problem here with being asked to save it is that
>> you aren't sending the proper MIME type. Look at the CGI docs for how
>> to do this.
>
> Ok, I'm still having some trouble getting this to work. I looked at the
> cgi docs but find them a little daunting. Is there some example code
> someone could point me to?
> Thanks.
Maybe an apache server with mod_ruby installed is what you needed,
google "mod_ruby" plz!
--
For some reasons,my EMail had been changed to "kdr2[#]163.com" now...
NO GNUS is Bad News.
------yours Killy Draw
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
simple ruby proxy
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password