File: binary_write.htm

package info (click to toggle)
libapache-asp-perl 2.63-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 4,120 kB
  • sloc: perl: 6,044; php: 409; sh: 62; lisp: 22; makefile: 10
file content (38 lines) | stat: -rwxr-xr-x 778 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/perl /usr/bin/asp-perl

<%
use File::Basename;

if($Request->QueryString('type') eq 'gif') {
    $Response->{ContentType} = 'image/gif';
    open(FILE, 'test.gif') || die "can't open test.gif";
    binmode FILE;
    $/ = undef;
    my $data = <FILE>;
    $Response->Clear;
    $Response->AddHeader('Content-Length', length $data);
    $Response->BinaryWrite($data);
    $Response->End;
} else {
%>

<!--#include file=header.inc-->

 We are going to load a gif through this
 same script as an example of doing a $Response->BinaryWrite()...

 <p>
 
 <img src="<%=basename($0)%>?type=gif">

 <p>

 Please note that if you are on Win32, you will need to 
 call binmode on a file handle before reading, if 
 its data is binary.

<!--#include file=footer.inc-->

<% } %>