FAQ Database Discussion Community


AsyncTask in Fragment not working and shows FATAL EXCEPTION: AsyncTask #1

android,android-asynctask,httpresponse,progressdialog
The following code when run crashes my app. I am calling it in the MainActivity. When run it tells me: FATAL EXCEPTION: AsyncTask #1 and directs me toward the ProgressDialog and Http Response Line import android.app.Fragment; import android.app.ProgressDialog; import android.os.AsyncTask; import android.os.Bundle; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup;...

Provide tab title with reportlab generated pdf

python,django,pdf-generation,httpresponse,reportlab
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 "(Anonymous) 127.0.0.1/whatnot", which is kinda ugly...

How to loop and get the specific value of the json object ,how can i use that json object to get the other entity present in that json object? [duplicate]

java,httpresponse
This question already has an answer here: How to loop through JSON array? 7 answers I am using java. I have pasted below response for reference. I need to loop the below JSON Array response. I can able to get the full response. But, I need to access the...

Should I return a status code or throw an exception in .Net Web Api 2

c#,asp.net,exception-handling,asp.net-web-api2,httpresponse
I have seen examples like this public IHttpActionResult GetProduct(int id) { Product item = repository.Get(id); if (item == null) { throw new HttpResponseException(HttpStatusCode.NotFound); } return Ok(item); } But I have also imagine this is an option public IHttpActionResult GetProduct(int id) { Product item = repository.Get(id); if (item == null) {...

http ResponseWriter duplicate answer golang

http,go,httpresponse
func main() { http.HandleFunc("/", foo) http.ListenAndServe(":3000", nil) } func foo(w http.ResponseWriter, r *http.Request) { s:= "name" fp := path.Join("templates", "index.html") tmpl, err := template.ParseFiles(fp) if err != nil { panic(err) } if err := tmpl.Execute(w, s); err != nil { panic(err) } fmt.Println("successfull Operation!!") } This code displays 2 "successfull...

Redirect to external url with parameters in django

python,django,redirect,post,httpresponse
I want when a user do something in my view then i redirect him to another website with some parameters as POST method Like when you submit a form. I think its may be something like this: return HttpResponseRedirect("url","parameters") How can i do that?...

Django xhtml2pdf 'HttpResponse' does not have the buffer interface

python,django,httpresponse,xhtml2pdf
I'm trying and making some tests for outputting pdfs with Django. I'm using the xhtml2pdf project installed with pip. I looked at an example for sending a pdf to the browser and succedeed, but when trying with a template of mine, an error appears. It reads: 'HttpResponse' does not have...

winCE C# HttpWebresponse timeout

c#,http,httprequest,windows-ce,httpresponse
I'm programming a Windows CE 6 device and want to make a request on a local Server! The device and the Server are in the same Wireless Network. The device tries to perform a getresquest() on the Server. public int test() { string var1 = "whatever"; req = (HttpWebRequest)WebRequest.create("http://192.168.x.x/test.php?var1=" +...

Slim PHP custom http response pages

php,httpresponse,http-status-code-403,slim
Ok I have read the docs on Slim PHP and read quite a few tutorials, and have an application nicely under way. However I am trying to get to grips with things such as customizing the HTTP response codes. I have managed to get the following : $app->notfound('template.file', array( 'data'...

When should I set HttpResponse.SuppressContent to true

c#,asp.net,httpresponse
I wrote HTTP module which validates url and in case if it has special symbols I'm redirecting to the root. I found different examples how to do it and someone suggested to set HttpResponse.SuppressContent property to true. But I'm not sure what will happen in that case. Msdn says that...

Send bitmap file in an HTTP response without using any libraries

python,python-2.7,httpresponse,bmp
I want to send a bitmap file in an HTTP response, but I have no idea how to do it; I tried different ways but all failed. Only text can be sent, I just want to know where to begin. This is related code client_connection.sendall("HTTP/1.1 200 OK\n" +"Content-Type: image/bmp\n" +"Content-Lenth:%d"%size...

exception while using HttpResponse response = client.execute(request);

android,exception,httpresponse,android-debug
I am trying to do the same as this guy here and I am using AsyncTask to call the executeHttpPost. However, by debugging the application, when it reaches the line HttpResponse response = client.execute(request); it skip everything to the line if (in != null) { I am pretty sure that...

How intercept response and modify response body with play framework 2.2.x? [closed]

java,filter,httpresponse,playframework-2.2,interceptor
I need to intercept request and response. I have already intercepted request. But I cant intercept response and get response body with java. I need to intercept response in play framework 2.2.x with java

Response byte[] to String[]

java,android,response,httpresponse
I get a byte[] response from a server with access token information: @Override public void onSuccess(int statusCode, Header[] headers, byte[] response) { Log.d("RESPONSE: ", new String(response)); } Response is: D/RESPONSE:﹕ {"access_token":"8863e1a8c16e2ce70b4d5a04a209e265bc1efe91","expires_in":3600,"token_type":"Bearer","scope":null} How could I parse this response to easily get any object(access_token, expires_in, token_type, scope) of response? ...

GAE Python - Accessing values in Response object

python,api,httprequest,httpresponse
I'm getting response from an API where response.text looks as follows: { "message": "Queued. Thank you.", "id": "<[email protected]>" } I want to access the ID, for which I am using following code: response.text['id'] However this results in the following error: TypeError: string indices must be integers However if I take...

When a friend sends me link it sometimes doesn't work like in his computer?

http,url,webserver,httprequest,httpresponse
I read somewhere that it's because the URL doesn't contain the body of the HTTP request. Is it true? If so, can someone please explain? Thanks!...

How to get only string from HTTPResponse RestApi Android

android,http-post,httpresponse,webmethod
I have tried this code snippet to get the response from android using HTTPResponse String s=""; try { HttpClient httpClient=new DefaultHttpClient(); HttpPost httpPost=new HttpPost("http://10.0.0.8:7777/HttpPostServlet/servlet/Login"); List<NameValuePair> list=new ArrayList<NameValuePair>(); list.add(new BasicNameValuePair("uname", valuse[0])); list.add(new BasicNameValuePair("pwd",valuse[1])); httpPost.setEntity(new UrlEncodedFormEntity(list)); HttpResponse httpResponse= httpClient.execute(httpPost); HttpEntity...

Django: Passing value from template to view

django,django-forms,django-views,streaming,httpresponse
I HAD this situation: Clicking on a html submit button, I call views.stream_response which "activates" views.stream_response_generator which "activates" stream.py and return a StreamingHttpResponse and I see a progressive number every second up to m at /stream_response/: 1 2 3 4 5 6 7 8 //e.g. my default max value for...

HttpResponseMessage.Content as an attachment for an email

asp.net-mvc,api,httpresponse,email-attachments
I need some help, really urgent. I have an API that returns an '.xls' file, using HttpResponseMessage. What I am trying to do is to get that file and attach it to an email that I am sending. Could anyone help me with this? Please keep in mind that I...

VB.Net XML Parsing Issue

xml,vb.net,parsing,httpresponse
I am having some difficulty parsing some XML information in to a richtextbox. I am pulling an XML file from a stream and the data is coming through successfully but when I try to view the elements I think there is a problem. Here is a snippet of the stream...

Add special characters to HttpContext.Current.Response.AddHeader()

internet-explorer,c#-4.0,httpresponse
I want to generate PDF file with special characters. My code is as follows: MemoryStream memoryStream = // get memory stream relevant to pdf file HttpContext.Current.Response.Clear(); HttpContext.Current.Response.Buffer = true; HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF32; HttpContext.Current.Response.AddHeader("Content-Disposition", string.Format("attachment;filename={0}.pdf", downloadLink)); HttpContext.Current.Response.ContentType = @"application/pdf";...

How to set the title of a pdf file in browser?

node.js,pdf,http-headers,httpresponse
I am using nodejs server to serve static files. When the pdf file is served, the browser displays the title as URL of the pdf path. 127.0.0.1:8080/docs/sample How can I set this to a custom title say "Sample" I have tried following things but no luck : res.setHeader('Content-Disposition', 'inline;filename="sample.pdf"'); Setting...

How to send parameters with url and get response in android

android,httpresponse
I am performing login task and getting data from PHP server in json format. In response, I am getting a 'success' tag that containing User-ID like this {"message":"You have been successfully login","success":"75"} I get that value as "uid" in the same activity and move to next page. Now in next...

Is there a normalized way to send request execution duration in HTTP Headers?

http,httpresponse,network-protocols
I believe everything is in the question ! Proposals : - "Execution Duration" - "Exec Time"...

Convert HttpWebResponse to HttpResponse

c#,.net,vb.net,http,httpresponse
In C# or VB.Net, there is a way to translate an HttpWebResponse object to an HttpResponse, or get directlly an HttpResponse from a HttpWebRequest instance? Example of what I try to do (it does not work): Dim request As HttpWebRequest = DirectCast(WebRequest.Create(url2), HttpWebRequest) Dim repsonse As HttpResponse = request.GetResponse() ...

In which format (HTML/markdown/JSON) should I receive some formatted text from my server?

android,json,httpresponse
I am receiving JSON responses from my sever. Generally it is structuted data. But I am stuck in a particular case where, the data can be of any number of items, each item will have a heading text and some more lines. a markdown example to show my use-case: **Heading**...

Write JSON response to a text view

android,json,httpresponse
I am authenticating an external system via a REST API. The http authentication request is of the Basic Authorization form. The response is in JSON format. I am running this code under an AsyncTask. url The GET url of the API. credentials is the authentication credentials. It is a string....

response sendRedirect() processing

java,jsp,httpresponse
if(condition true){ request.sendRedirect("//Some URL");} // Some other code Now my question is when we redirect, the some other code will execute or not ? If execute when, before sendRedirect or after sendRedirect ? ...

How to render pdf into web browser in RoR

ruby-on-rails,ruby,pdf,ruby-on-rails-4,httpresponse
I have files in server for whom i want to keep the url confidential. For this, i created a controller that fetch the data and ultimately render it to the web broswer. In the view <%= link_to "Click to view the file", file_proxy( user.pdf_file_url ) %> In users_heper.rb def file_proxy(url)...

Web API issue with sending compressed response

c#,json,asp.net-web-api,compression,httpresponse
I have been working on getting gzip/deflate compression working on Web API responses. I have been using the code from Github - MessageHandlers.Compression. However it didn't appear to work. There was no Content-Encoding header appearing in the Google Developer console or in Firebug in Firefox and the Content-Length was consistently...

Missing last 8 bytes of file when downloading from HTTPS

c#,httpresponse,file-transfer
I have a strange situation. A code I wrote uses Excel Interop to create an XLS file and saves it to the server. This file is then transmitted using System.Web.HttpResponse, and deleted afterwards. My problem is, when I download this file from an outward facing demo site while using HTTPS...

How to measure request and response time of server?

android,json,httprequest,httpresponse
I am using asynctask and json parsing for getting response from server,How can i measure request and response time,following is code of my web service,can any one help me with this?............................ public class JSONParser { static InputStream is = null; static JSONObject jObj = null; static String json = "";...

Calculating length of string that contains Unicode characters

c#,json,string,unicode,httpresponse
We have been struggling with calculating the length of a string which contains Unicode characters e.g (Word characters such as ’) that get pasted into our systems's text-area's then get saved. When we need to return that same saved string and we need to calculate our Response content-length the normal...

Get Content-Disposition parameters

c#,http,webclient,asp.net-web-api2,httpresponse
How do I get Content-Disposition parameters I returned from WebAPI controller using WebClient? WebApi Controller [Route("api/bla/bla/bla")] public HttpResponseMessage GetFile(int fileId) { try { var file = GetSomeFile(fileId) HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK); response.Content = new StreamContent(new MemoryStream(file)); response.Content.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment"); response.Content.Headers.ContentDisposition.FileName =...

What headers must be processed in a specific order in an HTTP response?

http,header,httpresponse
I am trying to identify what three headers, if present in an HTTP response, always have to be processed in a specific order. I have done a good amount of reading in my text: Web Application Architecture by Shklar and Rosen, and I have done research online but my research...

Handle http request that has timedout while in reality request was processed by server successefully

php,android,httpresponse
Consider the next case. I'm posting something to the server via my app. I've set up connection and respose timeout to 3000ms for example. In the case of slow internet connection user app will throw exception which will be handled to notify the user that request has timedout, but in...

Is it possible to eavesdrop http response?

security,encryption,server,web-api,httpresponse
I am new in network security area, now I am designing a REST web api. The question is that could http response and request be eavesdropped? If it is impossible, then I don't need encrypt the response json file and the request parameter....

Some sites do not allow requesting the same file twice (IDM)

c#,asp.net,pdf,web,httpresponse
Some sites do not allow requesting the same file twice : I face the previous error when i try to download my pdf in button click event: private void AddReportToResponse(LocalReport report ) { string mimeType; string encoding; string extension; string[] streams = new string[100]; Warning[] warnings = new Warning[100]; Response.Clear();...

What is the professional way of serving HTTP 206 responses

http,http-headers,httpresponse
If a server is set-up to handle Range requests, by accepting bytes for instance, then there are roughly two ways of sending a valid request to that server. The first is to set the Range header to something like Range: 0-, meaning that we want the first byte of whatever...

Http response codes not changing, calling die() acceptable?

php,api,httpresponse,http-response-codes
I have developed a php (5.5) API to interface with the databases on my server. So far everything is running smoothly except for the part where I want to send http response codes. If for example a user is not found in my database I want to return 404 to...

Django, Ajax- HttpResponse does not send json

ajax,json,django,httpresponse
Django 1.7.2/ python 3.4 this code is about 'like'. if user click the 'like' button, ajax calls 'pushLike'. if the user has liked the article before(saved inside Mysql), delete the row on table(DB). or if the user is not liking the article, create a row and insert it on the...

Best ERROR RESPONSE I should send from Server to Android?

android,server,httpresponse
I am developing a communication's system between an Android App and a Server. I am using Retrofit API for the Android's communication with the Server. When I do a GET (from Android side) to get info from the Server, I use a CallBackTask method like this: public void testGet() {...

Downloaded octet-stream then encoding as pdf; can't get line endings worked out

pdf,encoding,httpresponse,fiddler
Tools that I'm using for this: Chrome Notepad++ Sublime Text 3 Fiddler WinMerge Adobe Acrobat Reader X Synopsis I have downloaded a pdf twice, once through Chrome as an experimental control; once again through a raw /GET request via Fiddler which returns me an octet-stream. To this point, I can...

Multiple HttpResponses in Django

python,django,httpresponse
I have a program that prints data in a step by step process. Ex: data = {'a', 'b'} for op in data: if op == 'a': print 'Hello' elif op == 'b': print 'Bye' This is the functional layout in the views.py class in my django project. Each print statement...

Return specific HTTP response status in JSP

jsp,tomcat,tomcat7,httpresponse
I want to have a custom error code in my JSP, to prevent a special condition from happening: boolean error; // do error checking here if (error) { throw new javax.xml.ws.http.HTTPException(400); } However, this ends up throwing a 500 to the client, since the server interprets the exception as an...

Send .PDF file generated in memory via Resposne

c#,http,itextsharp,servicestack,httpresponse
So I have problem with Resposne file. I can send some file but it is corrupted. I know my pdf librabry works fine (checked on console app) public void Get(ClaimExportRequest exportRequest) { var str = ExportToPdf(claimDataTable); using (var streams = new MemoryStream(str)) { base.Response.AddHeader("Content-Disposition", "attachment; filename=report.pdf"); base.Response.AddHeader("Content-Length", str.Length.ToString(CultureInfo.InvariantCulture)); base.Response.ContentType =...

C# CR must be followed by LF

c#,c,sockets,http,httpresponse
I write a very simple HTTP server by myself, and I use the C# Windows Form to retrieve the content of my HTTP server. My C# program always said protocol violation, CR must be followed by LF. I know this issue can be solved by adding Configuration Files to C#...

Get and store cookie (from Set-Cookie) from an AJAX POST response

javascript,ajax,cookies,http-headers,httpresponse
I have a simple jQuery AJAX POST code: $.ajax({ type: "POST", url: AppConstants.URLs.PROXY, data: message, xhrFields: { withCredentials: true }, success: function(data, status, xhr) { console.log("Cookie: " + xhr.getResponseHeader("Set-Cookie")); } }); and I wish to get the cookie and save it using cookies-js. But according to http://www.w3.org/TR/XMLHttpRequest/#the-getallresponseheaders%28%29-method: Return all response...

Best practice for 404 page for API

json,api,rest,http-status-code-404,httpresponse
I am writting REST API now. I faced with one problem - how 404 page in api should look like. Of course it will be better to show user link to the API documentation. But what about page in general. Should it be beautiful page or just simple text also...

how to download a zip file using angular

angularjs,asp.net-web-api,httpresponse,zipfile,pushstreamcontent
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: 'arraybuffer'. Still isn't...

How to detect if network connection is down while downloading file using InputStream and FileOutputStream in android?

android,inputstream,httpresponse,fileoutputstream,httpentity
I am downloading a file and then writing it into sdcard using following code: HttpResponse response = httpClient.execute(request); HttpEntity entity = response.getEntity(); InputStream is = entity.getContent(); File file = new File(Environment.getExternalStorageDirectory()+"/MyProject/data"); FileOutputStream fos = new FileOutputStream(file); int inByte; while((inByte = is.read()) != -1){ fos.write(inByte); System.out.println("in while loop inByte: "+inByte); }...

send redirect and setting cookie, using laravel 5

php,laravel,redirect,httpresponse
I have written this code, that sets a cookie in client's browser, and after that must redirect the client to 'home' route, $response = new Response(); $response->withCookie(cookie()->forever('language', $language)); $response->header('Location' , url('/home')) ; return $response ; the client receives these headers but the client doesn't make request for the "home" route...

Download file prompt when using WebAPI HttpResponseMessage

c#,model-view-controller,web-api,httpresponse,fileresult
I have a method in my API that returns a HttpResponseMessage: [HttpGet, HoodPeekAuthFilter] public HttpResponseMessage GlobalOverview() { try { StatsRepo _statsRepo = new StatsRepo(); string file = _statsRepo.IncidentData().AsCSVString(); if (file == null) { return Request.CreateResponse(HttpStatusCode.NoContent); } HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK); result.Content = new StringContent(file); result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");...

bad URI(is not URI?): {“message”:“d64”,“type”:“success”}

ruby-on-rails,api,httprequest,httpresponse,httparty
Am using httparty to send API request, I want to get output response after i sent request, url = HTTParty.post("https://example.com/api/sendhttp.php", :query => { :authkey => "authkeyvalue", :mobiles => mobileNos, :message => messages, :sender => "senderid", :route => "routeid", :response => 'json' }) response = HTTParty.get(url) puts response.body, response.code, response.message, response.headers.inspect...