How to know if an HTTP request header value exists

if (Request.Headers[“XYZComponent”].Count() > 0) … will attempted to count the number of characters in the returned string, but if the header doesn’t exist it will return NULL, hence why it’s throwing an exception. Your second example effectively does the same thing, it will search through the collection of Headers and return NULL if it doesn’t … Read more

How to encode UTF8 filename for HTTP headers? (Python, Django)

This is a FAQ. There is no interoperable way to do this. Some browsers implement proprietary extensions (IE, Chrome), other implement RFC 2231 (Firefox, Opera). See test cases at http://greenbytes.de/tech/tc2231/. Update: as of November 2012, all current desktop browsers support the encoding defined in RFC 6266 and RFC 5987 (Safari >= 6, IE >= 9, … Read more

Send multipart/form-data files with angular using $http

Take a look at the FormData object: https://developer.mozilla.org/en/docs/Web/API/FormData this.uploadFileToUrl = function(file, uploadUrl){ var fd = new FormData(); fd.append(‘file’, file); $http.post(uploadUrl, fd, { transformRequest: angular.identity, headers: {‘Content-Type’: undefined} }) .success(function(){ }) .error(function(){ }); }

Show image using file_get_contents

You can use readfile and output the image headers which you can get from getimagesize like this: $remoteImage = “http://www.example.com/gifs/logo.gif”; $imginfo = getimagesize($remoteImage); header(“Content-type: {$imginfo[‘mime’]}”); readfile($remoteImage); The reason you should use readfile here is that it outputs the file directly to the output buffer where as file_get_contents will read the file into memory which is … Read more