httpresponse

Empty space in filename issue while downloading file

淺唱寂寞╮ 提交于 2020-01-03 08:18:07
问题 Following java code is being used to download a requested log file throgh a web application: protected HttpServletResponse response; .... response.setContentType("application/octet-stream"); String filename = OrgName + ".log"; response.setHeader("Content-Disposition", "attachment; filename= " + filename); OutputStream os = response.getOutputStream(); os.write(getFile()); os.close(); Problem comes when OrgName contains a space like "Xyz Pvt Ltd", in this case file will be download with name

“ The remote server returned an error: (401) Unauthorized ”

痴心易碎 提交于 2020-01-03 05:33:11
问题 I am trying to verify if my URLs get a response. in other words, i am trying to check if the authentication has succeeded approaching the site. I used: $HTTP_Request = [System.Net.WebRequest]::Create('http://example.com') $HTTP_Response = $HTTP_Request.GetResponse() $HTTP_Status = [int]$HTTP_Response.StatusCode If ($HTTP_Status -eq 200) { Write-Host "Site is OK!" } Else { Write-Host "The Site may be down, please check!" } $HTTP_Response.Close() and I got the response: The remote server

http post giving illegal state Exception

安稳与你 提交于 2020-01-03 02:41:16
问题 this is code which I use for HTTP post public void postData() { //DineOutActivity doa = null; HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost("192.168.1.112/andro/index.php/androctrl/test/"); try { //food item Spinner spinner = (Spinner) findViewById(R.id.spinner1); String fooditem = spinner.getSelectedItem().toString(); TextView mDateDisplay = (TextView)findViewById(R.id.textView2); String Date = mDateDisplay.toString(); TextView mTimeDisplay = (TextView

HttpContext.Current.Response.AddHeader() not setting Content-Type header

纵饮孤独 提交于 2020-01-01 19:06:52
问题 I'm using third-party software to render PDFs from html documents. I created a small test project and using the OnClick event of an <asp:Button> I was able to read a html document from a directory and render it as a PDF with no problems. The response is created as follows: HttpContext.Current.Response.Clear(); HttpContext.Current.Response.AddHeader("Content-Type", "application/pdf"); HttpContext.Current.Response.AddHeader("Content-Disposition", String.Format("{0}; filename=Test.pdf;", "inline

Protractor: HTTP Response Testing

社会主义新天地 提交于 2020-01-01 16:42:09
问题 I'm using Protracotr for e2e testing. I want to test response from HTTP in protractor. Basically: I have running some NodeJS server. I want to send request to this server Receive some JSON data Parse those data Check if they are correct I'm using "http" NODEJS Lib to make http calls GET+POST. var http = require('http'); describe("Some test", function() { function httpGet(siteUrl) { http.get(siteUrl, function(response) { response.setEncoding('utf8'); response.on("data", function(chunk) {

Django: return a StreamingHttpResponse on an existing html page

折月煮酒 提交于 2020-01-01 02:58:07
问题 Since it is better to have a single question for each issue, be patient if is similar to another part of another my question related to the same project. The situation: I have a form on html in which I can set a number and when it is submitted, it is call views.stream_response which pass the value to stream.py and it returns a StreamingHttpResponse and "virtual" blank browser page appears ( /stream_response/ ) in which I can see a progressive number every second up to m : 1 2 3 .. m stream.py

Get HTTP code from org.apache.http.HttpResponse

半世苍凉 提交于 2019-12-31 10:56:10
问题 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 HTTP status code as either an int or String? Thanks a bunch! 回答1: Use HttpResponse.getStatusLine(), which returns a StatusLine object containing the status code, protocol version and "reason". 回答2: I have used httpResponse.getStatusLine()

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

余生颓废 提交于 2019-12-31 08:03:13
问题 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 using this application, but I'm struggling to find out how. This would be the most convenient way, as it would allow me to leave both client and server code unmodified. Can anyone assist as I'd like to intercept the HTTP response being sent from

ASP.NET 4: HttpResponse open in NEW Browser?

耗尽温柔 提交于 2019-12-31 07:53:51
问题 I am using a PDF generater that utlizes HttpResponse. Is there a way (perhaps passing a header tag) to open the PDF in a NEW windows instead of the same one? I don't want the user to be directed away from the website... Here's the code I'm using: System.Web.HttpResponse response = System.Web.HttpContext.Current.Response; response.Clear(); response.AddHeader("Content-Type", "application/pdf"); response.AddHeader("Content-Disposition", "inline; filename=" + downloadName + "; size=" +

Uncompress GZIPed HTTP Response in Java

泪湿孤枕 提交于 2019-12-30 06:14:37
问题 I'm trying to uncompress a GZIPed HTTP Response by using GZIPInputStream . However I always have the same exception when I try to read the stream : java.util.zip.ZipException: invalid bit length repeat My HTTP Request Header: GET www.myurl.com HTTP/1.0\r\n User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; fr; rv:1.9.2) Gecko/20100115 Firefox/3.6\r\n Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n Accept-Language: fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3\r\n Accept