How can I replace Apache HTTP code 404 to 200

From: http://www.askapache.com/htaccess/apache-status-code-headers-errordocument.html Create a blank file in your main web directory named 404.. can be blank. Add this to your .htaccess file: Redirect 200 /404 ErrorDocument 404 /404 That will change the Apache ErrorDocument to the /404 file. But the Redirect line causes requests for /404 to issue a 200 OK response instead of a … Read more

Returning http status code from Web Api controller

I did not know the answer so asked the ASP.NET team here. So the trick is to change the signature to HttpResponseMessage and use Request.CreateResponse. [ResponseType(typeof(User))] public HttpResponseMessage GetUser(HttpRequestMessage request, int userId, DateTime lastModifiedAtClient) { var user = new DataEntities().Users.First(p => p.Id == userId); if (user.LastModified <= lastModifiedAtClient) { return new HttpResponseMessage(HttpStatusCode.NotModified); } return request.CreateResponse(HttpStatusCode.OK, … Read more

jQuery – get AJAX response headers

For backward compatibility with XMLHttpRequest, a jqXHR object will expose the following properties and methods: getAllResponseHeaders() and getResponseHeader(). From the $.ajax() doc : http://api.jquery.com/jQuery.ajax/ For jQuery > 1.3 success: function(res, status, xhr) { alert(xhr.getResponseHeader(“myHeader”)); }

ASP.NET How To Stream File To User

I wouldn’t call Response.Close() or Response.End(). Response.End() will stop the page execution/rendering at that point. No code following Response.End() will be run. The response is terminated at that point with no further output added to the stream. Response.Close() is similar to Response.End(), but allows code to be executed after it is called (but no further … Read more

Execute code in Django after response has been sent to the client

The method I am going for at the moment uses a subclass of HttpResponse: from django.template import loader from django.http import HttpResponse # use custom response class to override HttpResponse.close() class LogSuccessResponse(HttpResponse): def close(self): super(LogSuccessResponse, self).close() # do whatever you want, this is the last codepoint in request handling if self.status_code == 200: print(‘HttpResponse successful: … Read more

setcookie, Cannot modify header information – headers already sent [duplicate]

The warning is clear. Warning: Cannot modify header information – headers already sent by (output started at C:\xampp\htdocs\test\index.php:9) in C:\xampp\htdocs\test\index.php on line 12 Cookies are sent in the HTTP response header. Since the HTML content already started, you cannot go back to the header and add the cookie. From http://php.net/setcookie: setcookie() defines a cookie to … Read more