开发者

What are the right headers to send for Android devices to download from webserver?

I have a perl webserver that generates images on the fly. The content length is not known beforehand so my Android browser always gives me开发者_如何学JAVA a download failed error.

I looked at http://developer.android.com/reference/org/apache/http/impl/entity/StrictContentLengthStrategy.html and I'm not sure if I understand it correctly.

I sent a Transfer-Encoding: chunked header but I'm still having the same problem when downloading it from the phone.


Add the Content-Length header. You did not provide any code, so I'm invoking my magic crystal ball.

Change from:

print $cgi->header('image/something');
print $image_obj->generate;

to:

my $image_data = $image_obj->generate;
print $cgi->header(
    Content_Type   => 'image/something',
    Content_Length => length $image_data,
);
print $image_data;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜