problems sending binary data in cgi 
Author Message
 problems sending binary data in cgi

Hi there,

I'm trying to send binary data (e.g. gif file) to a web browser using
the following code:

f = File.open(gif_filename, "rb")
content = f.read(filesize)
f.close

print "Content-type: image/gif\n\n"
print content

I'm using ruby for windows. I'm getting problems because every 0x0a
will be converted to 0x0d 0x0a. Must I use another method to print
binary data for output? I've found nothing in the ruby documentation.

Cheers,

Helmut



Mon, 01 Aug 2005 06:26:46 GMT  
 problems sending binary data in cgi

Quote:
> Hi there,

> I'm trying to send binary data (e.g. gif file) to a web browser using
> the following code:

> f = File.open(gif_filename, "rb")
> content = f.read(filesize)
> f.close

> print "Content-type: image/gif\n\n"
> print content

> I'm using ruby for windows. I'm getting problems because every 0x0a
> will be converted to 0x0d 0x0a. Must I use another method to print
> binary data for output? I've found nothing in the ruby documentation.

perhaps

  f.binmode

but i'm on unices so can't test this.

-a

--

 ====================================
 | Ara Howard
 | NOAA Forecast Systems Laboratory
 | Information and Technology Services
 | Data Systems Group
 | R/FST 325 Broadway
 | Boulder, CO 80305-3328

 | Phone:  303-497-7238
 | Fax:    303-497-7259
 ====================================



Mon, 01 Aug 2005 06:51:53 GMT  
 problems sending binary data in cgi
Quote:


> perhaps

>   f.binmode

> but i'm on unices so can't test this.

Hi Ara,

sorry, that's not the problem. I've used f.binmode as well as
f.read(filename, "rb") where b is for binary.

But thanks for your help.

Cheers,

Helmut



Wed, 03 Aug 2005 23:00:13 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Tk 8.2 send of binary data to Tk 7.6 application corrupts data

2. send binary data through serial port

3. Sending binary data to network printer?

4. Sending binary data over RS232 without conversion to ascii

5. transfering binary data from a cgi script

6. howto: send application binary data to tcl channel.

7. Sending binary data

8. sending binary data in expect

9. Problem while uploading a binary file using cgi module

10. Special Problem and Solution regarding: CGI Binary File Uploading on Windows

11. Problems with uploading binary files using cgi module

12. Problem sending binary files with fcopy

 

 
Powered by phpBB® Forum Software