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
25
votes
7 answers

How to specify a generic type class for Swagger API response

I have about 40 APIs that have similar base response structure as follows: { "lastAccessed": "2015-30-08:14:21:45T", "createdOn": "2015-30-07:09:04:10T", "lastModified": "2015-30-08:14:21:45T", "isReadOnly": "false", …
as3rdaccount
  • 3,711
  • 12
  • 42
  • 62
24
votes
1 answer

HttpCookieCollection.Add vs HttpCookieCollection.Set - Does the Request.Cookies collection get copied to the Response.Cookies collection?

I just want to clear this up. I know that if I have set a cookie on a previous request, it will show up in my Request.Cookies collection. I want to update my existing Cookie. Are the cookies from my Request.Cookies collection already copied to…
smartcaveman
  • 41,281
  • 29
  • 127
  • 212
24
votes
5 answers

How can I get access to the Angular 2 http response body without converting it to string or json?

I would like to copy a REST response into a blob but I am unable to do some because blob() and arrayBuffer() have not yet been implemented in the Response Object. The Response Body is a private variable. ... return this.http.get(url, {params:…
sschueller
  • 533
  • 1
  • 6
  • 18
24
votes
3 answers

Stream directly to response output stream in handler method of Spring MVC 3.1 controller

I have a controller method that handles ajax calls and returns JSON. I am using the JSON library from json.org to create the JSON. I could do the following: @RequestMapping(method = RequestMethod.POST) @ResponseBody public String getJson() { …
John S
  • 21,212
  • 8
  • 46
  • 56
23
votes
2 answers

In IIS7.5 what module removes the body of a 400 Bad Request

I have written ASP.NET (4.0) code that sets the Response.StatusCode to 400 if the data posted to the server is in valid. I place useful information in the response body in the format that the request accepts header asks for. eg an html message…
Simon Francesco
  • 1,561
  • 16
  • 28
23
votes
3 answers

In Express.js why does code after res.json() still execute?

In Node with Express, I have a piece of code like this. if (req.body.var1 >= req.body.var2){ res.json({success: false, message: "End time must be AFTER start time"}); console.log('Hi') } console.log('Hi2') //other codes I…
davidx1
  • 3,525
  • 9
  • 38
  • 65
23
votes
4 answers

Adding header in response in filter?

I need to add the header in each response. I am planning to do below public class MyFilter extends OncePerRequestFilter { @Override protected void doFilterInternal(HttpServletRequest request, …
emilly
  • 10,060
  • 33
  • 97
  • 172
23
votes
3 answers

how to download a zip file

I am trying to download a zip file from my web api controller. It is returning the file but I am getting a message the zipfile is invalid when i try to open. I have seen other posts about this and the response was adding the responseType:…
texas697
  • 5,609
  • 16
  • 65
  • 131
23
votes
4 answers

Android JSON HttpClient to send data to PHP server with HttpResponse

I am currently trying to send some data from and Android application to a php server (both are controlled by me). There is alot of data collected on a form in the app, this is written to the database. This all works. In my main code, firstly I…
Scoobler
  • 9,696
  • 4
  • 36
  • 51
23
votes
2 answers

Should I return a 401 or a 405 response code to a REST API user without sufficient access?

I'm developing an API which will also have an authentication/authorization component. Anybody, regardless of authentication status, will be able to write (POST), but depending on if you are unauthenticated, authenticated as a normal user or…
Chris W.
  • 37,583
  • 36
  • 99
  • 136
23
votes
4 answers

Unable to locate FromStream in Image class

I have the following code: Image tmpimg = null; HttpWebRequest httpWebRequest = (HttpWebRequest)HttpWebRequest.Create(url); HttpWebResponse httpWebReponse = (HttpWebResponse)httpWebRequest.GetResponse(); Stream stream =…
user896692
  • 2,351
  • 7
  • 36
  • 57
22
votes
4 answers

HttpContext.Response.Body.Position = 0 - "Specified method is not supported" error

I've got some logging middleware I've setup that grabs and logs information utilizing HttpContext. I need to set the position of the HttpResponse.Body to 0 in order to read the whole stream, however, no matter what I try, it throws "Specified method…
expenguin
  • 1,052
  • 2
  • 21
  • 42
22
votes
6 answers

Apache HTTP Client Removal from API23, will that have an effect on Volley?

As we have known that Apache HTTP Client removed in API 23 Apache HTTP Client Removal However, Volley library currently still uses Apache's library such as import org.apache.http.Header; import org.apache.http.HttpEntity; import…
BNK
  • 23,994
  • 8
  • 77
  • 87
22
votes
5 answers

Get Content-Disposition parameters

How do I get Content-Disposition parameters I returned from WebAPI controller using WebClient? WebApi Controller [Route("api/mycontroller/GetFile/{fileId}")] public HttpResponseMessage GetFile(int fileId) { try { …
The One
  • 4,560
  • 5
  • 36
  • 52
22
votes
2 answers

How to pass model fields to a JsonResponse object

Django 1.7 introduced the JsonResponse objects, which I try to use to return a list of values to my ajax request. I want to pass >>> Genre.objects.values('name', 'color') [{'color': '8a3700', 'name': 'rock'}, {'color': 'ffff00', 'name': 'pop'},…
speendo
  • 13,045
  • 22
  • 71
  • 107