Puzzling


(Ruby Tuesday) #1

Hi, I have these 2 files, one work and the other does not.

#!c:/apps/ruby/bin/ruby.exe
print "Content-type: text/html \n\n\n"
print "1st line "
print "2nd line "
print "3rd line "

And this is the other one(DOES NOT WORK!)
#!c:/apps/ruby/bin/ruby.exe
print "Content-type: text/plain \n\n\n"
print "1st line "
print "2nd line "
print "3rd line "

The only difference is that the 2nd file has text/plain in the header
instead of text/html. Please advise. Thanks


(Osuka Adartse) #2

Ruby Tuesday wrote:

Hi, I have these 2 files, one work and the other does not.

#!c:/apps/ruby/bin/ruby.exe
print "Content-type: text/html \n\n\n"
print "1st line "
print "2nd line "
print "3rd line "

And this is the other one(DOES NOT WORK!)
#!c:/apps/ruby/bin/ruby.exe
print "Content-type: text/plain \n\n\n"
print "1st line "
print "2nd line "
print "3rd line "

The only difference is that the 2nd file has text/plain in the header
instead of text/html. Please advise. Thanks
Well, both work…what error are you getting?, how are you using those?
my results:
Content-type: text/html

1st line 2nd line 3rd line
and:
Content-type: text/plain

1st line 2nd line 3rd line


(Ruby Tuesday) #3

Oops … I’m using them on the browser. Both of those files is in cgi-bin
directory. I wonder why the text/plain gave me errors.

I’m using Apache2.0.48/Ruby1.8.1. Thanks

The error(s)
First, a pop up windows with the message as follow:
Some files can harm your computer. If the file information below
look suspicious, or you do not fully trust the source, do not open or
save this file.

 File name: ex2.rb
 File type:

Would you like to open the file or save it to your computer?

Open Save Cancel More Info

When I click open, a DOS window flashed quickly then dissapear.

Thanks

“Osuka Adartse” rocioestradacastaneda@prodigy.net.mx wrote in message
news:403698DF.8010307@prodigy.net.mx

···

From: webserver

Ruby Tuesday wrote:

Hi, I have these 2 files, one work and the other does not.

#!c:/apps/ruby/bin/ruby.exe
print "Content-type: text/html \n\n\n"
print "1st line "
print "2nd line "
print "3rd line "

And this is the other one(DOES NOT WORK!)
#!c:/apps/ruby/bin/ruby.exe
print "Content-type: text/plain \n\n\n"
print "1st line "
print "2nd line "
print "3rd line "

The only difference is that the 2nd file has text/plain in the header
instead of text/html. Please advise. Thanks
Well, both work…what error are you getting?, how are you using those?
my results:
Content-type: text/html

1st line 2nd line 3rd line
and:
Content-type: text/plain

1st line 2nd line 3rd line


(Bob X) #4

Ruby Tuesday wrote:

Oops … I’m using them on the browser. Both of those files is in cgi-bin
directory. I wonder why the text/plain gave me errors.

I’m using Apache2.0.48/Ruby1.8.1. Thanks

The error(s)
First, a pop up windows with the message as follow:
Some files can harm your computer. If the file information below
look suspicious, or you do not fully trust the source, do not open or
save this file.

 File name: ex2.rb
 File type:
 From:       webserver

Would you like to open the file or save it to your computer?

Open Save Cancel More Info

When I click open, a DOS window flashed quickly then dissapear.

Thanks

“Osuka Adartse” rocioestradacastaneda@prodigy.net.mx wrote in message
news:403698DF.8010307@prodigy.net.mx

Ruby Tuesday wrote:

Hi, I have these 2 files, one work and the other does not.

#!c:/apps/ruby/bin/ruby.exe
print "Content-type: text/html \n\n\n"
print "1st line "
print "2nd line "
print "3rd line "

And this is the other one(DOES NOT WORK!)
#!c:/apps/ruby/bin/ruby.exe
print "Content-type: text/plain \n\n\n"
print "1st line "
print "2nd line "
print "3rd line "

The only difference is that the 2nd file has text/plain in the header
instead of text/html. Please advise. Thanks

Well, both work…what error are you getting?, how are you using those?
my results:
Content-type: text/html

1st line 2nd line 3rd line
and:
Content-type: text/plain

1st line 2nd line 3rd line

Because Apache is interpreting text/html to be HTML and when it sees
text/plain is looks to the OS for help. My guess is that when you run
the text/plain one it tries to download the file yes? That is because
the OS does not have a set MIME type for text/plain.

Or something along those lines… ; )

HTH


(Jon A. Lambert) #5

“Ruby Tuesday” wrote:

The error(s)
First, a pop up windows with the message as follow:
Some files can harm your computer. If the file information below
look suspicious, or you do not fully trust the source, do not open or
save this file.

Internet Explorer is the problem. When a content type of text/plain is sent
Internet explorer attempts to open the file using the information in the
registry based on the file extension.

What Internet Explorer will do is take the output and attempt to run it
through the ruby interpreter. The same problem happens if you have
ActiveState Perl installed and attempt to view web pages that have *.pl
extensions and content-type text/plain.

BTW this is incorrect.
print “Content-type: text/html \n\n\n”

It should be
print “Content-type: text/html \r\n\r\n”


(Osuka Adartse) #6

Ruby Tuesday wrote:

Oops … I’m using them on the browser. Both of those files is in cgi-bin
directory. I wonder why the text/plain gave me errors.
Thought so :wink:

I’m using Apache2.0.48/Ruby1.8.1. Thanks

The error(s)
First, a pop up windows with the message as follow:
Some files can harm your computer. If the file information below
look suspicious, or you do not fully trust the source, do not open or
save this file.

 File name: ex2.rb
 File type:
 From:       webserver

Would you like to open the file or save it to your computer?

Open Save Cancel More Info

When I click open, a DOS window flashed quickly then dissapear.

And using IE? or I’m wrong?, that behaviour I couldn’t recreate it on
Mozilla(which does the smart thing), IE does the dialog thing, I guess
this is caused because IE is more intimate with windows and looks up the
file types for the .rb extension, either it saves the file or
downloads it and then executes it(if clicking on open) hence the
flashing dos window.

Maybe using a .rb extension isn’t that good('cos IE will look it up in
filetypes).

I’ve to wonder if you’re familiar with eruby, I asked how You were using
it 'cos as normal scripts those run fine and if I paste’em inside a
.rhtml those also worked as expected(even on IE).

Eruby at http://modruby.net/

look up msg id 92598 to see my setup 2.0.47 + 1.8.1
http://www.ruby-talk.org/ruby/ruby-talk/index.shtml


(Ruby Tuesday) #7

In my apache configuration, httpd.conf, I have the following:

DefaultType text/plain

I did change it to text/html and restart Apache, it’s no go either.

Any advise? Thanks

“Robert” bobx@linuxmail.org wrote in message
news:romdnbpDFdNNDKvd4p2dnA@adelphia.com

Ruby Tuesday wrote:

Oops … I’m using them on the browser. Both of those files is in
cgi-bin

directory. I wonder why the text/plain gave me errors.

I’m using Apache2.0.48/Ruby1.8.1. Thanks

The error(s)
First, a pop up windows with the message as follow:
Some files can harm your computer. If the file information below
look suspicious, or you do not fully trust the source, do not open
or

···
 save this file.

 File name: ex2.rb
 File type:
 From:       webserver

Would you like to open the file or save it to your computer?

Open Save Cancel More Info

When I click open, a DOS window flashed quickly then dissapear.

Thanks

“Osuka Adartse” rocioestradacastaneda@prodigy.net.mx wrote in message
news:403698DF.8010307@prodigy.net.mx

Ruby Tuesday wrote:

Hi, I have these 2 files, one work and the other does not.

#!c:/apps/ruby/bin/ruby.exe
print "Content-type: text/html \n\n\n"
print "1st line "
print "2nd line "
print "3rd line "

And this is the other one(DOES NOT WORK!)
#!c:/apps/ruby/bin/ruby.exe
print "Content-type: text/plain \n\n\n"
print "1st line "
print "2nd line "
print "3rd line "

The only difference is that the 2nd file has text/plain in the header
instead of text/html. Please advise. Thanks

Well, both work…what error are you getting?, how are you using those?
my results:
Content-type: text/html

1st line 2nd line 3rd line
and:
Content-type: text/plain

1st line 2nd line 3rd line

Because Apache is interpreting text/html to be HTML and when it sees
text/plain is looks to the OS for help. My guess is that when you run
the text/plain one it tries to download the file yes? That is because
the OS does not have a set MIME type for text/plain.

Or something along those lines… ; )

HTH


(Ruby Tuesday) #8

Hi Osuka, yes you are right. I’m using IE6. I’m still puzzled.

Yes, I’m familiar with eruby. I’d rather to use mod_ruby and eruby if I can.
But since I could not find mswin32 binaries for mod_ruby for quite
sometimes, I had to use the CGI method. Perhaps if you can tell me where to
get mswin32 version of the latest eruby/mod_ruby for Ruby 1.8.1 and Apache
2.0.48, I’ll take that route.

Much Appreciated.

PS: I downloaded Mozilla and test it. It all work out! So, what’s the deal
with IE6?
“Osuka Adartse” rocioestradacastaneda@prodigy.net.mx wrote in message
news:4036BD4F.1070601@prodigy.net.mx

Ruby Tuesday wrote:

Oops … I’m using them on the browser. Both of those files is in
cgi-bin

directory. I wonder why the text/plain gave me errors.
Thought so :wink:

I’m using Apache2.0.48/Ruby1.8.1. Thanks

The error(s)
First, a pop up windows with the message as follow:
Some files can harm your computer. If the file information below
look suspicious, or you do not fully trust the source, do not open
or

···
 save this file.

 File name: ex2.rb
 File type:
 From:       webserver

Would you like to open the file or save it to your computer?

Open Save Cancel More Info

When I click open, a DOS window flashed quickly then dissapear.

And using IE? or I’m wrong?, that behaviour I couldn’t recreate it on
Mozilla(which does the smart thing), IE does the dialog thing, I guess
this is caused because IE is more intimate with windows and looks up the
file types for the .rb extension, either it saves the file or
downloads it and then executes it(if clicking on open) hence the
flashing dos window.

Maybe using a .rb extension isn’t that good('cos IE will look it up in
filetypes).

I’ve to wonder if you’re familiar with eruby, I asked how You were using
it 'cos as normal scripts those run fine and if I paste’em inside a
rhtml those also worked as expected(even on IE).

Eruby at http://modruby.net/

look up msg id 92598 to see my setup 2.0.47 + 1.8.1
http://www.ruby-talk.org/ruby/ruby-talk/index.shtml


(Bob X) #9

Jon A. Lambert wrote:

“Ruby Tuesday” wrote:

BTW this is incorrect.
print “Content-type: text/html \n\n\n”

It should be
print “Content-type: text/html \r\n\r\n”

Is that a Ruby thing? That certainly isn’t how Perl does it. Perl does
the following:

print “Content-type: text/html\n\n”;

Which I believe is the standard header.


(Osuka Adartse) #10

Ruby Tuesday wrote:

Hi Osuka, yes you are right. I’m using IE6. I’m still puzzled.

Yes, I’m familiar with eruby. I’d rather to use mod_ruby and eruby if I can.
But since I could not find mswin32 binaries for mod_ruby for quite
sometimes, I had to use the CGI method. Perhaps if you can tell me where to
get mswin32 version of the latest eruby/mod_ruby for Ruby 1.8.1 and Apache
2.0.48, I’ll take that route.
In the msg 92598 is link to mod_ruby binaries, but I didn’t managed to
make’em work, but eruby is good enough for me.

Much Appreciated.

PS: I downloaded Mozilla and test it. It all work out! So, what’s the deal
with IE6?
uh? bad design? not following standards? whatever, I just know that IE
is a risk so I just don’t use it(besides tabbed browsing is addictive).
“Osuka Adartse” rocioestradacastaneda@prodigy.net.mx wrote in message
news:4036BD4F.1070601@prodigy.net.mx

Eruby at http://modruby.net/

look up msg id 92598 to see my setup 2.0.47 + 1.8.1
http://www.ruby-talk.org/ruby/ruby-talk/index.shtml
look there(msg id)

Hint always look on Ruby mirrors for binaries, latest eruby is 1.0.5.

second AFAIK(or remember) Mingw32 binaries can be used with
MSWIN(pragprog) so maybe you want to give it try(is newer and the dl is
small 59kb)

I guess You’re using the pragprog version? then:
http://www.ibiblio.org/pub/languages/ruby/binaries/mswin32/ext/eruby-1.0.4-i386-mswin32-1.8.zip

If you want to try the mingw bins then:
http://www.ibiblio.org/pub/languages/ruby/binaries/mingw/1.8/ext/eruby-1.0.5-i386-mingw32-1.8.tar.gz

have fun :wink:
Adartse


(Jon A. Lambert) #11

“Ruby Tuesday” wrote

PS: I downloaded Mozilla and test it. It all work out! So, what’s the deal
with IE6?

One way around the problem is to change the extension from .rb to
.cgi or remove the extension. Apache2 will execute the script based on the
shebang line.

mod_ruby works only on Apache 1.x


(Charles Comstock) #12

Robert wrote:

Jon A. Lambert wrote:

“Ruby Tuesday” wrote:

BTW this is incorrect.
print “Content-type: text/html \n\n\n”

It should be
print “Content-type: text/html \r\n\r\n”

Is that a Ruby thing? That certainly isn’t how Perl does it. Perl does
the following:

print “Content-type: text/html\n\n”;

Which I believe is the standard header.

I’m pretty sure under the rfs your supposed to do \r\n\r\n, but I think
most servers are setup to just look for a single blank line before
actual content, and so they generally just look for a \n and thus the
\n\n works. But technically it’s supposed to be \r\n\r\n I think.

Charles Comstock


(Mark Hubbart) #13

If I understand right, when IE gets a text/plain file, It assumes it’s
not really plaintext, and tries to open it as if you had double-clicked
the file. This would be peculiar to IEWin, I believe.

Now, I don’t have anything running windows around here, so I can’t test
this solution, but:

When I installed mod_ruby with my Apace installation, the Apache config
code that I snipped from a webpage gave ruby executables a ".rbx"
extension rather than “.rb”. Perhaps if you change your httpd.conf to
accept both extensions… then rename your text/plain example to use
the “.rbx” extension. I suspect that that would solve the problem.

Good luck!

-Mark

···

On Feb 20, 2004, at 7:44 PM, Ruby Tuesday wrote:

Hi Osuka, yes you are right. I’m using IE6. I’m still puzzled.

PS: I downloaded Mozilla and test it. It all work out! So, what’s the
deal
with IE6?


(Jon A. Lambert) #14

“Osuka Adartse” wrote:

I guess You’re using the pragprog version? then:
http://www.ibiblio.org/pub/languages/ruby/binaries/mswin32/ext/eruby-1.0.4-i386-mswin32-1.8.zip

If you want to try the mingw bins then:
http://www.ibiblio.org/pub/languages/ruby/binaries/mingw/1.8/ext/eruby-1.0.5-i386-mingw32-1.8.tar.gz

have fun :wink:
Adartse

Do you know what the difference is between erb.rb and eruby.exe?
Is it just that eruby is compiled or are there additional features?

···


J. Lambert


(John Long) #15

---- Jon A. Lambert wrote: ----

mod_ruby works only on Apache 1.x

I’m running it right now on Apache 2.

···

John Long
www.wiseheartdesign.com


(Charles Comstock) #16

Charles Comstock wrote:

Robert wrote:

Jon A. Lambert wrote:

“Ruby Tuesday” wrote:

BTW this is incorrect.
print “Content-type: text/html \n\n\n”

It should be
print “Content-type: text/html \r\n\r\n”

Is that a Ruby thing? That certainly isn’t how Perl does it. Perl does
the following:

print “Content-type: text/html\n\n”;

Which I believe is the standard header.

I’m pretty sure under the rfs your supposed to do \r\n\r\n, but I think
most servers are setup to just look for a single blank line before
actual content, and so they generally just look for a \n and thus the
\n\n works. But technically it’s supposed to be \r\n\r\n I think.

Charles Comstock

Oops dunno what I was typing, I meant RFC, not rfs,

Charles Comstock

(Ruby Tuesday) #17

One way around the problem is to change the extension from .rb to
cgi or remove the extension. Apache2 will execute the script based on the
shebang line.
Well, the same problem appears with Perl(.pl) as well. Anyone has the same
issues. The header “Content-type: text/plain \r\n\r\n” gives me so much
grief in IE6.

mod_ruby works only on Apache 1.x
I’d love to run mod_ruby which is running in my Linux Redhat 9 but now I
have to use the windows server, I’m stuck — can’t find mod_ruby/eruby
binaries for mswin32 version. Anyone compiled that already? Please share.
Thanks

“Jon A. Lambert” jlsysinc@alltel.net wrote in message
news:001901c3f846$25288ec0$0200000a@agamemnon…

“Ruby Tuesday” wrote

PS: I downloaded Mozilla and test it. It all work out! So, what’s the
deal

···

with IE6?

One way around the problem is to change the extension from .rb to
cgi or remove the extension. Apache2 will execute the script based on the
shebang line.

mod_ruby works only on Apache 1.x


(Ruby Tuesday) #18

Hi Osuka, unfortunately I have no say in what browser to use - I’m stuck
with IE and MS-Windoze.

Reading from the reply, it seems that IE6 has a little bug with header
text/plain. Have anyone encounter that issues? Try to use text/plain and put
some reqular text afterward. It works fine with Mozilla but not with IE.
Thanks

“Osuka Adartse” rocioestradacastaneda@prodigy.net.mx wrote in message
news:40370FC0.4000608@prodigy.net.mx

Ruby Tuesday wrote:

Hi Osuka, yes you are right. I’m using IE6. I’m still puzzled.

Yes, I’m familiar with eruby. I’d rather to use mod_ruby and eruby if I
can.

But since I could not find mswin32 binaries for mod_ruby for quite
sometimes, I had to use the CGI method. Perhaps if you can tell me where
to

get mswin32 version of the latest eruby/mod_ruby for Ruby 1.8.1 and
Apache

2.0.48, I’ll take that route.
In the msg 92598 is link to mod_ruby binaries, but I didn’t managed to
make’em work, but eruby is good enough for me.

Much Appreciated.

PS: I downloaded Mozilla and test it. It all work out! So, what’s the
deal

with IE6?
uh? bad design? not following standards? whatever, I just know that IE
is a risk so I just don’t use it(besides tabbed browsing is addictive).
“Osuka Adartse” rocioestradacastaneda@prodigy.net.mx wrote in message
news:4036BD4F.1070601@prodigy.net.mx

Eruby at http://modruby.net/

look up msg id 92598 to see my setup 2.0.47 + 1.8.1
http://www.ruby-talk.org/ruby/ruby-talk/index.shtml
look there(msg id)

Hint always look on Ruby mirrors for binaries, latest eruby is 1.0.5.

second AFAIK(or remember) Mingw32 binaries can be used with
MSWIN(pragprog) so maybe you want to give it try(is newer and the dl is
small 59kb)

I guess You’re using the pragprog version? then:

http://www.ibiblio.org/pub/languages/ruby/binaries/mswin32/ext/eruby-1.0.4-i386-mswin32-1.8.zip

If you want to try the mingw bins then:

http://www.ibiblio.org/pub/languages/ruby/binaries/mingw/1.8/ext/eruby-1.0.5-i386-mingw32-1.8.tar.gz

···

have fun :wink:
Adartse


(Osuka Adartse) #19

Jon A. Lambert wrote:

Do you know what the difference is between erb.rb and eruby.exe?
Is it just that eruby is compiled or are there additional features?


J. Lambert
Good question, I haven’t used erb before, short and honest answer: not
really, I don’t.

AFAIK both embed Ruby, using the taskmanager I noticed that a page that
uses erb calls ruby.exe, but if is an eruby page it calls itself. Maybe
someone who really knows will answer. Note the description of ERB: “ERB
is an implementation of eRuby (embedded ruby)”.

ps: I just remembered that one “web app” that I installed, uses erb (I
thought it was eruby cgi, but no, it’s Ruby+cgi+ERB) maybe You would
want to take a look at it, in sourceforge or RAA look for Tdiary.


(Robert) #20

“Charles Comstock” cc1@cec.wustl.edu schrieb im Newsbeitrag
news:c18g6f$maq$2@newsreader.wustl.edu

Charles Comstock wrote:

Robert wrote:

Jon A. Lambert wrote:

“Ruby Tuesday” wrote:

BTW this is incorrect.
print “Content-type: text/html \n\n\n”

It should be
print “Content-type: text/html \r\n\r\n”

Is that a Ruby thing? That certainly isn’t how Perl does it. Perl does
the following:

print “Content-type: text/html\n\n”;

Which I believe is the standard header.

I’m pretty sure under the rfs your supposed to do \r\n\r\n, but I think
most servers are setup to just look for a single blank line before
actual content, and so they generally just look for a \n and thus the
\n\n works. But technically it’s supposed to be \r\n\r\n I think.

Charles Comstock

Oops dunno what I was typing, I meant RFC, not rfs,

Charles Comstock

Nevertheless you are right. The RFC requires \r\n sequences as line
termination in an HTTP header. Never mind what “Perl does”, it’s better to
just comply to the standard - “Better safe than sorry.” :slight_smile:

See
http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.1

Regards

robert