httpresponse

set timeout in httprequest android

情到浓时终转凉″ 提交于 2019-12-21 05:04:58
问题 I am using the following code to get data from the server with http request. HttpClient client = new DefaultHttpClient(); String URL = urlGenerator(); StringBuilder url = new StringBuilder(URL); HttpGet get = new HttpGet(url.toString()); HttpResponse response = client.execute(get); int status = response.getStatusLine().getStatusCode(); if(status == 200){ ... } Its working fine.But in case if the phone is connected to wifi or gprs 3g but internet is not working or internet connection is not

How to convert a Django HttpResponse to a Django render call

荒凉一梦 提交于 2019-12-21 04:31:21
问题 I have the following code def ajax_login_request(request): try: request.POST[u'login'] dictionary = request.POST except: dictionary = request.GET user = authenticate(username = dictionary[u'login'], password = dictionary[u'password']) if user and user.is_active: login(request, user) result = True else: result = False response = HttpResponse(json.dumps(result), mimetype = u'application/json') return response which is being called via ajax. I'm a noob and this is from an example in a book.

Set response headers not using filter - RESTeasy

谁说胖子不能爱 提交于 2019-12-21 04:21:28
问题 I am trying to set a header value in a response from a RESTful endpoint using RESTeasy. I know that I can read header parameters using @HeaderParam but I want to change the value of that header parameter for the response. How can I do this without using a filter? 回答1: RESTEasy can inject HttpResponse which enables you to set header parameters. @Path("/") public class MyService { @Context org.jboss.resteasy.spi.HttpResponse response; @GET @Path("/") public void setHeader(){ response

Set response headers not using filter - RESTeasy

北城以北 提交于 2019-12-21 04:21:16
问题 I am trying to set a header value in a response from a RESTful endpoint using RESTeasy. I know that I can read header parameters using @HeaderParam but I want to change the value of that header parameter for the response. How can I do this without using a filter? 回答1: RESTEasy can inject HttpResponse which enables you to set header parameters. @Path("/") public class MyService { @Context org.jboss.resteasy.spi.HttpResponse response; @GET @Path("/") public void setHeader(){ response

How to raise a 410 error in Django

不羁岁月 提交于 2019-12-21 03:54:10
问题 I'd like to return 410 errors at for some of my Django pages instead of returning 404s. Basically, instead of calling raise Http404('some error message') , I would like to instead call raise Http410('some error message') shortcut. I am confused because in django.http, the function Http404 is simply: class Http404(Exception): pass So if I do the same thing and create my Http410 function, I would assume it would look like: class Http410(Exception): pass However, doing this returns the exception

How to proxy HTTP requests in Spring MVC?

此生再无相见时 提交于 2019-12-21 03:33:30
问题 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 requesting client Here is what I've got so far: public void proxyRequest(HttpServletRequest request, HttpServletResponse response) { try { HttpUriRequest proxiedRequest = createHttpUriRequest(request); HttpResponse proxiedResponse = httpClient.execute

Web API Best Approach for returning HttpResponseMessage

放肆的年华 提交于 2019-12-20 10:19:55
问题 I have a Web API project and right my methods always returns HttpResponseMessage . So, if it works or fails I return: No errors: return Request.CreateResponse(HttpStatusCode.OK,"File was processed."); Any error or fail return Request.CreateResponse(HttpStatusCode.NoContent, "The file has no content or rows to process."); When I return an object then I use: return Request.CreateResponse(HttpStatusCode.OK, user); I would like to know how can I return to my HTML5 client a better encapsulated

How to return multiple files in HttpResponse Django

 ̄綄美尐妖づ 提交于 2019-12-20 02:28:08
问题 I have been wracking my brains in this problem. Is there a way in django to serve multiple files from a single HttpResponse? I have a scenario where i am looping through a list of json and want to return all those as file form my admin view. class CompanyAdmin(admin.ModelAdmin): form = CompanyAdminForm actions = ['export_company_setup'] def export_company_setup(self, request, queryset): update_count = 0 error_count = 0 company_json_list = [] response_file_list = [] for pb in queryset.all():

How can i change charset encoding in HTTP response in Java

落爺英雄遲暮 提交于 2019-12-19 19:55:38
问题 I have to fetch some JSON object from a remote server and for that i am using this function which is working great except that for sometime some weird data is getting fetched which i believe is because it is using ASCII charset to decode. Please find below thw method that i am using public HttpResponse call(String serviceURL,String serviceHost,String namespace,String methodName,String payloadKey, String payloadValue) throws ClientProtocolException,IOException,JSONException { HttpResponse

RestSharp RestResponse is truncating content to 64 kb

若如初见. 提交于 2019-12-19 11:09:11
问题 Hi I am using the RestSharp to create the request to my web API. Unfortunately the response.content does not contain full response, which I am able to see when I perform request through browser or fiddler. The content is being truncated to 64 kb. I am attaching my code below. Could you please advice what could solve this issue? var request = new RestRequest("Products?productId={productId}&applicationId={applicationId}", Method.GET); request.RequestFormat = DataFormat.Json; request