Download text/csv content as files from server in Angular

$http service returns a promise which has two callback methods as shown below. $http({method: ‘GET’, url: ‘/someUrl’}). success(function(data, status, headers, config) { var anchor = angular.element(‘<a/>’); anchor.attr({ href: ‘data:attachment/csv;charset=utf-8,’ + encodeURI(data), target: ‘_blank’, download: ‘filename.csv’ })[0].click(); }). error(function(data, status, headers, config) { // handle error });

What is the most appropriate HTTP status code to return if a required header is missing?

400 Bad Request It’s a user error in the request. Unlike with a 403, the client should be allowed to repeat their request, but only after modification: 10.4.1 400 Bad Request The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repeat the request without modifications. Edit As … Read more

Detecting the character encoding of an HTTP POST request

the default encoding of a HTTP POST is ISO-8859-1. else you have to look at the Content-Type header that will then look like Content-Type: application/x-www-form-urlencoded ; charset=UTF-8 You can maybe declare your form with <form enctype=”application/x-www-form-urlencoded;charset=UTF-8″> or <form accept-charset=”UTF-8″> to force the encoding. Some references : http://www.htmlhelp.com/reference/html40/forms/form.html http://www.w3schools.com/tags/tag_form.asp

How to make an HTTP get request in C without libcurl?

Using BSD sockets or, if you’re somewhat limited, say you have some RTOS, some simpler TCP stack, like lwIP, you can form the GET/POST request. There are a number of open-source implementations. See the “happyhttp” as a sample ( http://scumways.com/happyhttp/happyhttp.html ). I know, it is C++, not C, but the only thing that is “C++-dependant” … Read more