Questions tagged [httpresponse]

An HTTP response is a network message which is made of a body and metadata in the form of headers, according to HTTP specification. May also refer an HttpResponse class in software frameworks and libraries that automates relevant functionality

From W3C specification:

   Response      = Status-Line               ;
                   *(( general-header        ;
                    | response-header        ;
                    | entity-header ) CRLF)  ;
                   CRLF
                   [ message-body ]          ;

See also:

3825 questions
44
votes
8 answers

Remove Server Response Header IIS 8.0 / 8.5

How can we remove the server header response in IIS 8.0/8.5? My current server report: Microsoft-IIS/8.0 Microsoft-IIS/8.5 For IIS 7.0 I used the URLScan 3.1 however this is only supported for IIS 7.0 and not 8.x
BastianW
  • 2,628
  • 7
  • 29
  • 38
44
votes
6 answers

XlsxWriter object save as http response to create download in Django

XlsxWriter object save as http response to create download in Django?
Waheed
  • 645
  • 1
  • 6
  • 9
43
votes
5 answers

Return http 204 "no content" to client in ASP.NET MVC2

In an ASP.net MVC 2 app that I have I want to return a 204 No Content response to a post operation. Current my controller method has a void return type, but this sends back a response to the client as 200 OK with a Content-Length header set to 0.…
Jeremy Raymond
  • 5,817
  • 3
  • 31
  • 33
43
votes
5 answers

setcookie, Cannot modify header information - headers already sent

I am new to PHP, I practised PHP setcookie() just now and failed. http://localhost/test/index.php
Nano HE
  • 9,109
  • 31
  • 97
  • 137
43
votes
8 answers

Writing MemoryStream to Response Object

I am using the following code to stream pptx which is in a MemoryStream object but when I open it I get Repair message in PowerPoint, what is the correct way of writing MemoryStream to Response Object? HttpResponse response =…
Ali
  • 1,648
  • 2
  • 26
  • 48
42
votes
2 answers

Make http client synchronous: wait for response

I have some file to upload and some of the files failed because the post is asynchronous and not synchronous.. I'm trying to make this call as synchronized call.. I want to wait for the response. How can I make this call as synchronous? static async…
Alon Shmiel
  • 6,753
  • 23
  • 90
  • 138
41
votes
5 answers

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

In my Django application I want to keep track of whether a response has been sent to the client successfully. I am well aware that there is no "watertight" way in a connectionless protocol like HTTP to ensure the client has received (and displayed)…
Florian Ledermann
  • 3,187
  • 1
  • 29
  • 33
40
votes
5 answers

Django return HttpResponseRedirect to an url with a parameter

I have a situation in my project where i need to make a redirection of the user to an url containing a parameter, it is declared in the urls.py like: url(r'^notamember/(?P\w+)/$', notamember, …
dana
  • 5,168
  • 20
  • 75
  • 116
39
votes
4 answers

How to implement proper HTTP error handling in .NET MVC 2?

I've been struggling all day to implement error handling in my ASP.NET MVC 2 app. I've looked at a variety of techniques, but none work properly. I'm using MVC2 and .NET 4.0 (started the project before MVC3 was released; we'll upgrade after we…
Val
  • 2,291
  • 7
  • 34
  • 63
38
votes
4 answers

Reread a response body from JavaScript's fetch

fetch() returns promise which (if successful) resolves to a Response object. A very common thing to do is immediately call Response.json() to convert the response body to a JSON object. If the response body isn't valid JSON, then the Response.json()…
Craig Walker
  • 49,871
  • 54
  • 152
  • 212
37
votes
5 answers

What's the proper way to set the Location header for an HTTP 201 response in a Java Servlet application

Consider the following code sending an HTTP 201 "Created" response to the client: String url = "/app/things?id=42"; // example response.setStatus(HttpServletResponse.SC_CREATED); response.setContentType("text/plain"); …
les2
  • 14,093
  • 16
  • 59
  • 76
37
votes
3 answers

org.apache.http.ProtocolException: Target host is not specified

I have written a simple httprequest/response code and I am getting this below error. I have referenced httpclient, httpcore, common-codecs and common-logging in my classpath. I am very new to java and have no clue what is going on here. Please help…
ac11
  • 927
  • 2
  • 11
  • 18
37
votes
1 answer

Django: Add response header when using render or render_to_response

How do I add a response header to a Django response? I have: response = HttpResponse() response['Cache-Control'] = 'no-cache' return render(request, "template.html", {}) # Alternately using render_to_response # return…
user984003
  • 28,050
  • 64
  • 189
  • 285
34
votes
2 answers

Which HTTP errors should never trigger an automatic retry?

I'm trying to make a few microservices more resilient and retrying certain types of HTTP requests would help with that. Retrying timeouts will give clients a terribly slow experience, so I don't intend to retry in this case. Retrying 400s doesn't…
cahen
  • 15,807
  • 13
  • 47
  • 78
34
votes
3 answers

AttributeError: can't set attribute

I am working on a legacy django project, in there somewhere there is a class defined as follows; from django.http import HttpResponse class Response(HttpResponse): def __init__(self, template='', calling_context='' status=None): …
austiine
  • 470
  • 1
  • 5
  • 12