下载跟这个没关系的。
贴一段 Perl 的 CGI::Application::Plugin::Stream,这是用于在服务器端
发送文件的,可以看到 -type 用的是真实的 mime type,不是一律 octet-stream。
http://cpansearch.perl.org/src/PURDY/CGI-Application-Plugin-Stream-2.10/lib/CGI/Application/Plugin/Stream.pm
# Use FileHandle to make File::MMagic happy;
# bless the filehandle into the FileHandle package to make File::MMagic happy
require FileHandle;
bless $fh, "FileHandle";
# Check what headers the user has already set and
# don't override them.
my %existing_headers = $self->header_props();
# Check for a existing type header set with or without a hypheout a hyphen
unless ( $existing_headers{'-type'} || $existing_headers{'type'} ) {
my $mime_type;
eval {
require File::MMagic;
my $magic = File::MMagic->new();
$mime_type = $magic->checktype_filehandle($fh);
};
warn "Failed to load File::MMagic module to determine mime type: $@" if $@;
# Set Default
$mime_type ||= 'application/octet-stream';
$self->header_add('-type' => $mime_type);
}
unless ( $existing_headers{'Content_Length'}
|| $existing_headers{'-Content_Length'}
) {
$self->header_add('-Content_Length' => $size);
}
unless ( $existing_headers{'-attachment'}
|| $existing_headers{'attachment'}
|| grep( /-?content-disposition/i, keys %existing_headers )
) {
$self->header_add('-attachment' => $basename);
}
【 在 elf (精灵 | bbs.rains.cn 小雨如丝BBS) 的大作中提到: 】
: 还有一个header
: Content-Type: application/octet-stream
--
FROM 211.157.41.*