httpresponse

How to obtain just a single form field from an HttpResponse in Java and write it to a file?

☆樱花仙子☆ 提交于 2019-12-10 20:50:02
问题 I am calling a client's download service which sends back MIME data and attempting to save a zip file. The service does not simply return the file by itself but several other MIME fields as well. So when I open the inputstream using entity.getContent() I end up writing all of this data to my zip file whereas I only wish to write one part "Payload". I have searched and do not see anyway to obtain just the one individual part from the content. Code is below: HttpResponse response = services

Setting the charset of html response content to 1252

隐身守侯 提交于 2019-12-10 20:37:02
问题 I'm trying to send some data encoded in Windows 1252 (it's a CSV file) in an HTTP response, but somewhere along the way it's getting re-encoded to UTF-8 (no BOM). How can I make sure that the data stays in the correct encoding? var sb = new StringBuilder(); // Build the file from windows-1252 strings in the sb... HttpContext.Current.Response.Clear(); HttpContext.Current.Response.ClearHeaders(); HttpContext.Current.Response.ClearContent(); HttpContext.Current.Response.AddHeader("content

ASP.NET JavaScriptSerializer requires HttpResponse?

别等时光非礼了梦想. 提交于 2019-12-10 18:45:31
问题 It appears that the System.Web.Script.Serialization.JavascriptSerializer class tries to obtain the HttpResponse for the current request, presumably to apply appropriate character encoding. However this means that when you to to use the class with no HttpContext in scope, it blows up with the following exception + stack trace: [HttpException (0x80004005): Response is not available in this context.] System.Web.HttpContext.get_Response() +8753496 System.Web.Util.HttpEncoder.get_Current() +39

How can I configure HTTP Response Headers in a Struts2 Interceptor?

此生再无相见时 提交于 2019-12-10 18:24:02
问题 We currently have a java web application in the middle of migration from Struts 1 to Struts 2. We would like to configure X-Frame-Options and Content-Security-Policy headers for all our Struts 2 actions. We have a lot of actions and I want to avoid modifying them all separately if at all possible. the idea I currently have is the following interceptor which would be added to the default stack: import javax.servlet.http.HttpServletResponse; import org.apache.struts2.ServletActionContext;

AttributeError: 'Response' object has no attribute 'body_as_unicode' scrapy for python

删除回忆录丶 提交于 2019-12-10 18:05:52
问题 I am working with response in scrapy and keep on getting this message. I only gave the snippet where the error is occuring. I am trying to go through different webpages and need get the # of pages in that particular webpage. So I created A response object where I get the href for the next button but keep on getting AttributeError: 'Response' object has no attribute 'body_as_unicode' code working with. from scrapy.spiders import Spider from scrapy.selector import Selector from scrapy.http

How to output a binary document based on a HTML document using filters in Java

二次信任 提交于 2019-12-10 17:34:41
问题 This may be a little confusing but I having some trouble. My goal is to take an input HTML document and then process that document and use the HTML data to output a image document. For example, a user will request a URL, with some action=png in the querystring and then the filter will get invoked for the URL and output image document. I have tried everything but in my environment (Websphere), I am only able to output of one type. If the input type is text/html then I can only output a text

java.io.IOException: Invalid Http response

与世无争的帅哥 提交于 2019-12-10 16:16:32
问题 Now before you say there are questions like this I'd like to point out I've looked over most of them without any luck. Also I'm a first timer here so be gentle. I have this annoyance right now in my current program: Basically this part of my program uses a search engine to find torrent files. public static ArrayList<String> search(String args) throws IOException { args = args.replace(":", ""); ArrayList<String> list = new ArrayList<String>(); URL url = new URL("http://pirateproxy.net/search/"

Django to serve generated excel file

末鹿安然 提交于 2019-12-10 14:37:09
问题 I looked at the various questions similar to mine, but I could not find anything a fix for my problem. In my code, I want to serve a freshly generated excel file residing in my app directory in a folder named files excelFile = ExcelCreator.ExcelCreator("test") excelFile.create() response = HttpResponse(content_type='application/vnd.ms-excel') response['Content-Disposition'] = 'attachment; filename="test.xls"' return response So when I click on the button that run this part of the code, it

Single request to multiple asynchronous responses

和自甴很熟 提交于 2019-12-10 13:55:41
问题 So, here's the problem. iPhones are awesome, but bandwidth and latency are serious issues with apps that have serverside requirements. My initial plan to solve this was to make multiple requests for bits of data (pun unintended) and have that be how the issue of lots of incoming//outgoing data was handled. This is a bad idea for a lot of reasons, most obvious to me is that my poor database (MySQL) can't handle this very well. From what I understand it's better to request large chunks all at

Downloading Zip File through HttpResponse Java

穿精又带淫゛_ 提交于 2019-12-10 13:48:12
问题 So I'm grabbing a collection of blobs from a database (various mimetypes) and trying to zip them up to be downloaded by users through an http response. I can get the download to happen, but when I try to open the downloaded zip file it says "The archive is either in unknown format or damaged." I've tried the following code with application/zip, application/octet-stream, and application/x-zip-compressed, but I'm starting to assume that the issue is in how I'm adding the files. I'm also using