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
97
votes
2 answers

How to Use Content-disposition for force a file to download to the hard drive?

I want to force the browser to download a pdf file. I am using the following code : Click here to Download quotation It makes the browser open the pdf in a new window, but I want it to download to the…
Krish
  • 2,590
  • 8
  • 42
  • 62
91
votes
4 answers

Get HTTP code from org.apache.http.HttpResponse

I'm using the org.apache.http.HttpResponse class in my Java application, and I need to be able to get the HTTP status code. If I used .toString() on it, I can see the HTTP status code in there. Is there any other function that I can just get the…
Chiggins
  • 8,197
  • 22
  • 56
  • 81
89
votes
2 answers

What HTTP response headers are required

What HTTP response headers are required to be sent from server to the client? I working to optimize the HTTP response headers to minimize the HTTP response overhead. I know "overhead" is somewhat exaggerated, but I like a clean output. I see a lot…
Beni
  • 891
  • 1
  • 6
  • 4
77
votes
6 answers

How to get an specific header value from the HttpResponseMessage

I'm making an HTTP call. My response contains a session code X-BB-SESSION in the header section of the HttpResponseMessage object. How do I get that specific header value? I am using a foreach statement to iterate through all the headers (MSDN…
MikePR
  • 2,786
  • 5
  • 31
  • 64
73
votes
8 answers

Disable all default HTTP error response content in Tomcat

By default, Tomcat sends some HTML content back to the client if it encounters something like an HTTP 404. I know that via web.xml an can be configured to customize this content. However, I'd just like for Tomcat to not send anything in…
Rob Hruska
  • 118,520
  • 32
  • 167
  • 192
57
votes
2 answers

Any way to get the response body during HTTP errors?

I'm hitting an API that will occasionally throw a HTTP 403 error, and the response body can give some extra information in the form of json, however for the life of me I can't seem to get the information back out from the Alamofire response objects.…
Kevin DiTraglia
  • 25,746
  • 19
  • 92
  • 138
57
votes
6 answers

HTTP GET Request Status 204 Vs 404

I have 2 resources User and Album. A user has a list of albums. To get albums there are 2 REST API. user/{userId}/albums/{albumId} gets album by albumId. If not found returns 404 user/{userId}/albums gets all albums by userId. In this case, if a…
Navrattan Yadav
  • 1,993
  • 1
  • 17
  • 22
54
votes
6 answers

content type for mp3 download response

I have created a simple HTTP server which allows users to download files. But this does not seem to work for mp3 files. The content type currently is "application/misc". In order to make it work with mp3 files , I've tried "application/mp3" ,…
Vihaan Verma
  • 12,815
  • 19
  • 97
  • 126
52
votes
2 answers

jQuery - get AJAX response headers

How do we get access to the response headers when we fire an ajax request using jQuery? I tried with the below code as per the suggestions given in some sites. But xhr object is coming as null. I see an xhr object in this context. But it doesn't…
Apps
  • 3,284
  • 8
  • 48
  • 75
50
votes
5 answers

What is the proper HTTP response to send for requests that require SSL/TLS

I'm designing an RESTful API where some calls are public over HTTP, and some require an API key and encryption over HTTPS. I'm deliberating on what response code should be sent if an HTTP request is sent to one of the private resources. So far the…
gtd
  • 16,956
  • 6
  • 49
  • 65
48
votes
5 answers

Display image from http response with image content type

Let's say I have url and don't know what it will return. I perform ajax call to that url with javascript and get the content. So I test it's content-type and decide how to show response in my webpage. In case it is json or html or any other text, I…
ArVan
  • 4,225
  • 8
  • 36
  • 58
48
votes
10 answers

download csv file from web api in angular js

my API controller is returning a csv file as seen below: [HttpPost] public HttpResponseMessage GenerateCSV(FieldParameters fieldParams) { var output = new byte[] { }; if (fieldParams!= null) { using…
raberana
  • 11,739
  • 18
  • 69
  • 95
47
votes
3 answers

How do I use Fiddler to modify the status code in an HTTP response?

I need to test some client application code I've written to test its' handling of various status codes returned in an HTTP response from a web server. I have Fiddler 2 (Web Debugging Proxy) installed and I believe there's a way to modify responses…
w5m
  • 2,286
  • 3
  • 34
  • 46
47
votes
4 answers

Is there a website that returns 500 (and other) HTTP response codes for testing?

It's occurred to me that it would be useful to have a URL that would always return a 500, for the sake of testing client code that handles getting bad responses. And I can think of other projects that would benefit from URLs that would always return…
Mark
  • 1,746
  • 2
  • 18
  • 19
46
votes
6 answers

Does HTTP response "200 OK" give a guarantee that the document has been received by the machine who generated the HTTP request?

I have two machines, A and B. A sends an HTTP request to B and asks for some document. B responds back and sends the requested document and gives a 200 OK message, but machine A is complaining that the document is not received because of a network…
Naveen Suryawanshi
  • 513
  • 1
  • 4
  • 15