Posts Tagged ‘HTTP’

HTTP headers for binary file downloads

Thursday, November 29th, 2007

In case you need to send files from a webserver, use these HTTP headers:

Content-Type:application/octet-stream
Content-Disposition:attachment;filename=filename
Content-Length:100

Of course, you need to set your own content type, filename and file length. 🙂

URL Parameter Transforming

Friday, November 16th, 2007

Need to transform URL parameters and decode values such as “Hello%20World!”? Here is how:

Perl:

$s =~ s/%([\da-f][\da-f])/chr( hex($1) )/egi;

Java:

s = java.net.URLEncoder.encode(s, "UTF-8");

PHP:

$s = urldecode($s);