# Simple ruby proxy

**URL:** <https://www.ruby-forum.com/t/simple-ruby-proxy/77204>\
**Category:** Ruby\
**Created:** [November 25, 2006, 2:15am UTC](https://www.ruby-forum.com/t/simple-ruby-proxy/77204 "2006-11-25T02:15:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![maxbohr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/f4b2a3/32.png) [@maxbohr](https://www.ruby-forum.com/u/maxbohr)\
**Post date:** [November 25, 2006, 2:15am UTC](https://www.ruby-forum.com/t/simple-ruby-proxy/77204/1 "2006-11-25T02:15:21Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![maxbohr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/f4b2a3/32.png) [@maxbohr](https://www.ruby-forum.com/u/maxbohr)\
**Post date:** [November 25, 2006, 3:36am UTC](https://www.ruby-forum.com/t/simple-ruby-proxy/77204/2 "2006-11-25T03:36:04Z")

</div>

Max B. wrote:

> appreciated.  
> Best,  
> Max
> 
> –  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

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.

---

<div class="post-metadata">

**Author:** ![maxbohr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/f4b2a3/32.png) [@maxbohr](https://www.ruby-forum.com/u/maxbohr)\
**Post date:** [November 25, 2006, 4:41am UTC](https://www.ruby-forum.com/t/simple-ruby-proxy/77204/3 "2006-11-25T04:41:37Z")

</div>

Timothy G. wrote:

> Max B. wrote:
> 
> > appreciated.  
> > Best,  
> > Max
> > 
> > –  
> > Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> 
> 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.

---

<div class="post-metadata">

**Author:** ![maxbohr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/f4b2a3/32.png) [@maxbohr](https://www.ruby-forum.com/u/maxbohr)\
**Post date:** [November 25, 2006, 6:40am UTC](https://www.ruby-forum.com/t/simple-ruby-proxy/77204/4 "2006-11-25T06:40:22Z")

</div>

Max B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:

> > 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](http://163.com)” now…

NO GNUS is Bad News.

```
                                           ------yours Killy Draw

```
