httpresponse

Android get image from url SingleClientConnManager problem

耗尽温柔 提交于 2019-12-23 04:07:27
问题 I am using following code to get the images of a logo and save it in the database. DefaultHttpClient mHttpClient = new DefaultHttpClient(); HttpGet mHttpGet; HttpResponse mHttpResponse; HttpEntity entity; for (int reportsCount = 0; reportsCount < reportsArr.length; reportsCount++) { //Make a request to get our image mHttpGet = new HttpGet(reportsArr[reportsCount][1]); byte[] categoryLogoArr = null; try { mHttpResponse = mHttpClient.execute(mHttpGet); if (mHttpResponse.getStatusLine()

Spring what is the easiest way to return custom Http status, headers and body to Rest Client

江枫思渺然 提交于 2019-12-23 02:37:09
问题 I would like to return to my Rest Client the simplest answer. Only the: http status code 201 http status message Created http header Content Type http response body Custom string answer What is the easiest way? I've used to use ResponseEntity object this way: return new ResponseEntity<String>("Custom string answer", HttpStatus.CREATED); , but unfortunately, I can not simple pass http header in constructor. I have to create HttpHeaders object and there add my custom header like this:

Is there a way to complete the post back after writing out a file to the Response?

删除回忆录丶 提交于 2019-12-22 10:54:56
问题 I have a button that when clicked, will generate a PDF and write it out to the response. This is the basic structure of the code: try { using(Stream stream = generatePdf()) { var file = createFile(stream); file.Transmit(HttpContext.Current.Response); } } catch (Exception ex) { // Handle exception // Display Error Message } The transmit method contains the following code: response.AddHeader("Content-Disposition", String.Format("attachment; filename={0}", filename)); response.AddHeader("Content

Why does assigning a value to an unused variable make a difference in the functionality of this async code?

旧时模样 提交于 2019-12-22 09:54:10
问题 I've got this code: private async Task SavePlatypusComplianceFileOnServer(string year, string month) { string monthAsMM = ReportRunnerConstsAndUtils.GetMonthAsMM(month); HttpClient client = new HttpClient(); client.BaseAddress = new Uri(ReportRunnerConstsAndUtils.SERVER_BASE_ADDRESS); String uriToCall = String.Format("/api/PlatypusCompliance/{0}/{1}{2}", _unit, year, monthAsMM); HttpResponseMessage response = await client.PostAsync(uriToCall, null); } ...that works fine. On looking at it,

How to alter the body of a http response in a filter

谁说胖子不能爱 提交于 2019-12-22 08:18:43
问题 I am attempting to use a filter to check for HTML tags in a response body. The problem is that if I alter the body in the filter, it isn't altered when it gets to the client. I tried the solution shown here: Looking for an example for inserting content into the response using a servlet filter but it didn't help. I have two filters. SecureWrapperFilter wraps the request/response objects in our custom wrapper, and XSSFilter uses OWASP encode to encode for html content. The filters look like

How to measure request and response time of server?

风流意气都作罢 提交于 2019-12-22 07:01:10
问题 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 = ""; // constructor public JSONParser() { } // function get json from url // by making HTTP POST or GET method public JSONObject makeHttpRequest(String url, String method, List

Google API for Google Docs, requesting a list of documents — 400 Bad Request

让人想犯罪 __ 提交于 2019-12-22 06:51:31
问题 After authentication from google servers for google docs, I do a simple getResponse, but I get a 400 Bad Request. I can't understand where am I going wrong. The sample code is, below private void executeRefreshAlbums() { HttpRequest request = transport.buildGetRequest(); request.url = GoogleDocsUrl.forDefaultPrivateFull(); System.out.println("URL = "+request.url); try { HttpResponse response = request.execute(); System.out.println("Response = "+response.getContent()); } catch (IOException e)

Rest API calls with PowerApps

送分小仙女□ 提交于 2019-12-22 05:17:46
问题 I am playing around with Microsoft PowerApps and Microsoft Flow. I am trying to figure out how to make API calls from PowerApps and return the results(Status and Body) to a field such as a text box in my app. I can make the HTTP requests through Flow and put them in a static file such as an excel spreadsheet...etc. I can also make the calls from a PowerApps control such as a button but all I know how to do with it is return it to something like an excel file, when really I want to return it

Tornado - What is the difference between RequestHandler's get_argument(), get_query_argument() and get_body_argument()?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-22 04:42:38
问题 When to use RequestHandler.get_argument() , RequestHandler.get_query_argument() and RequestHandler.get_body_argument() ? What is the use-case for each of them? Also what does the request.body and request.argument do in these cases? Which are to be used in which scenarios? And, is there a request.query or something similar too? 回答1: Most HTTP requests store extra parameters (say, form values) in one of two places: the URL (in the form of a ?foo=bar&spam=eggs query string), or in the request

Web API HttpResponseMessage content return is incomplete

岁酱吖の 提交于 2019-12-21 17:01:14
问题 I would like to return a csv generated from my database using Web API 5.0 It is working fine except that the csv returned is truncated. I assume the issue is on the MemoryBuffer management, but I can't find where it is. My code (solved): IEnumerable<MasterObsTrip> masterTripList = _obsvMasterRepo.GetObsTrips(vesselName, dateYear, port, obsvCode, obsvTripCode, obsvProgCode, lastModifiedDateYear, lastModifiedBy, statusCode); IList<MasterObsTripModel> masterTripModelList = new List