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

ASP.NET WebAPI: How to control string content returned to client?

In WebAPI, say I return a string wrapped in an HTTP response: return Request.CreateResponse(HttpStatusCode.BadRequest, "Line1 \r\n Line2"); When invoking this action from jQuery, the response text is treated before it is returned. So in the xhr, I…
danludwig
  • 46,965
  • 25
  • 159
  • 237
16
votes
8 answers

HttpResponse using android issue: execute always causes exception?

I've been working on an Android project and I'm at a point where I want to ask some API for information. Seems like this should be very basic! Here's the general gist of my code: private InputStream retrieveStream2(String url) { …
Ethan Sherr
  • 413
  • 2
  • 5
  • 12
16
votes
3 answers

Is it possible to return an HttpResponse in django with text & a json object?

In my view function, I'd like to return a json object (data1) and some text/html (form). Is this possible? Here is part of my views.py: if request.is_ajax() and request.method == 'POST': ... if form.is_valid(): answer =…
Harshil Parikh
  • 291
  • 2
  • 3
  • 8
16
votes
3 answers

Angular 6: HttpErrorResponse SyntaxError: Unexpected token s in JSON

I am posting a request and I am suppose to receive a 'success' string back as response. I am getting an HttpResponseError with the following information posted in the image below. PurchaseOrderService postPurchaseOrderCustom(purchaseOrderCustom:…
user3701188
  • 638
  • 3
  • 7
  • 23
16
votes
5 answers

Node streams cause large memory footprint or leak

I'm using node v0.12.7 and want to stream directly from a database to the client (for file download). However, I am noticing a large memory footprint (and possible memory leak) when using streams. With express, I create an endpoint that simply pipes…
lebolo
  • 2,120
  • 4
  • 29
  • 44
16
votes
5 answers

Provide tab title with reportlab generated pdf

This question is really simple, but I can't find any data on it. When I generate a pdf with reportlab, passing the httpresponse as a file, browsers that are configured to show files display the pdf correctly. However, the title of the tab remains…
Alvaro
  • 11,797
  • 9
  • 40
  • 57
16
votes
4 answers

ContainerRequestFilter ContainerResponseFilter doesn't get called

I am trying to learn jersey by creating a small RESTful service. I want to use the Filters for specific reasons(Like I want to use the ContainerResponseFilter for CORS headers to allow cross domain requests). However, I am just not able to get…
user2973475
  • 357
  • 1
  • 3
  • 12
16
votes
1 answer

How can I get the response code from a VolleyError?

I'm looking for a way to get the response code of a thrown VolleyError. My ErrorListener looks like this: Response.ErrorListener errorListener = new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { …
Bart Burg
  • 4,786
  • 7
  • 52
  • 87
15
votes
5 answers

How to get only the response code from a HTTP Request in Ruby

I have a list of urls, I need to check which of the following urls are valid. The code I used is require 'net/http' url = 'http://mysite.com' res = Net::HTTP.get_response(URI.parse(url.to_s)) puts res.code Here I can check the response code 200…
Amal Kumar S
  • 15,555
  • 19
  • 56
  • 88
15
votes
1 answer

Why is the gzip minimum length directive not being respected?

If I understand correctly it's better not to gzip small resources as they might actually get bigger while still having a performance hit on the CPU. So using the gzip_min_length directive is an obvious solution to that. However, when trying this on…
Jonathan
  • 1,041
  • 1
  • 12
  • 21
15
votes
1 answer

How to proxy HTTP requests in Spring MVC?

I have an application built on top of Spring MVC. I want to write simple proxy that processes requests as follows: send the same HTTP request to some specific server capture HTTP response from this specific server return the same answer to…
15
votes
5 answers

In Django, How do I get escaped html in HttpResponse?

The following code in one of my views returns unescaped html string which cannot be parsed in frontend since it is an Ajax request. return render_to_response(template_name, { 'form': form, redirect_field_name: redirect_to, …
Nullpoet
  • 10,949
  • 20
  • 48
  • 65
15
votes
1 answer

Add Response Header to JAX-RS Webservice

I am trying add some response headers to some of my webservice calls. I wrote my webservice using CXF 2.1.2 and JAX-RS. I need to return an object and I also want to add some headers to the Response. Without returning a javax.ws.rs.core.Response…
jconlin
  • 3,806
  • 6
  • 31
  • 32
15
votes
4 answers

Response.Write and UpdatePanel

I generate a vcard that I send to the client using the following code snippet: Response.AddHeader("Content-Disposition", string.Format("attachment; filename={0}", fileNameOnly)); Response.ContentType = "text/x-vcard"; Response.ContentEncoding =…
laconicdev
  • 6,360
  • 11
  • 63
  • 89
14
votes
2 answers

django: return image data from a view

I want a view to return image data. so something along the lines of return HttpResponse(image_data, mimetype=”image/png”) I know I can do a file.read() to get the image data, but because the image is small (like 1x1 px) I want to just store it as a…
w--
  • 6,427
  • 12
  • 54
  • 92