httprequest

Angular4: HttpClient - many requests in succession

隐身守侯 提交于 2019-12-04 23:23:38
I have a http get request to get a list of some items from a feed. the feed API requires a page param, which is limited to 20. I would like to get first 60 instead, so I need to make 3 requests requestOptions.params.set('page', 1); this.http.get(environment.api+ '.feed.json', requestOptions) requestOptions.params.set('page', 2); this.http.get(environment.api+ '.feed.json', requestOptions) requestOptions.params.set('page', 3); this.http.get(environment.api+ '.feed.json', requestOptions) what is the best way to deal with it to get an ordered list? I am not very fond of nesting Your service:

jQuery.ajax() log the HTTP request

风格不统一 提交于 2019-12-04 22:12:30
问题 I have a function that sends an HTTP POST request and i want to log it for debugging purposes. Here is the function: function serverRequest(URL, DATA, callback) { $.ajax({ url: URL, type: "POST", dataType: "text", contentType: "text/xml", processData: false, data: DATA, success: function (response) { console.log(response); callback(response); }, error: function (response) { console.log(response); callback(null); } }); } How can i log the whole HTTP POST request (HTTP Header + data), as soon

Using Httprequest to get pictures from given URL

会有一股神秘感。 提交于 2019-12-04 21:59:21
I'm trying to get pictures from webcams. There is a php-python web service to get the pictures from webcams and serve them: it serves the picture like http://ip/jpeg/camera=1 . private HttpWebRequest request; private HttpWebResponse response; private CookieContainer container; private Uri uri; private string _user; private string _pass; private string _ip; //Login code as seen in the previous section should be here //GetImages is meant to run as a separate thread private void GetImages(string camNo) { //create the GET request for the JPEG snapshot (found at /jpeg on the IP Camera)

While reading from socket how to detect when the client is done sending the request?

℡╲_俬逩灬. 提交于 2019-12-04 20:19:53
I am now writing a http server and I am having problem with reading from a socket. My problem is that the inputStream from the client never ends and it keeps reading until the client is closed. I know that the client doesn't close the connection with the server immediately after sending the http request. How can I quit the while loop when client has sent all the request data (i.e. headers + body). while (in.hasNextLine()) { String line = in.nextLine(); if (line.equals("")){ // last line of request header is blank break; // quit while loop when last line of header is reached } else { request =

how to get source file in HttpRequest for uploading file

对着背影说爱祢 提交于 2019-12-04 19:41:14
I have a problem with upload file in REST web service using java. I don't know how to get the source file. The curl command is like that curl --upload-file /home/student1/text1.txt http://localhost:20260/project/resources/user1/sub-folder/text1.txt My question is anyone know how to get the source file url "/home/student1/text1.txt" in REST web service @PUT method?Or any other way to get it? thanks I'm assuming that curl uses mltipart/form-data as content type for the upload. The filename would be part of the Content-Disposition header of the first MIME part. I'm not terribly familiar with JAX

How to make HTTP REQUEST to mantisBT's REST API using angular Http?

与世无争的帅哥 提交于 2019-12-04 19:36:19
Background: I installed mantisBT 2.5.0 on a test server, enabled the REST API (which is currently in beta phase). After that I generated an API Key and I have tried to make a test HTTP request using the swagger page on /api/rest/swagger. This works fine. (I could only access this page after renaming the .htaccess to _htaccess) What I want to do: I want to implement a feature in my app to enable sending "easy" bug reports without visiting mantisBT directly. To test the API I implemented this function, which just calls a "get issue" request. If this works, I can implement a method to create an

Python: How to use requests library to access a url through several different proxy servers?

假如想象 提交于 2019-12-04 18:56:30
As it says in the title, I am trying to access a url through several different proxies sequentially (using for loop). Right now this is my code: import requests import json with open('proxies.txt') as proxies: for line in proxies: proxy=json.loads(line) with open('urls.txt') as urls: for line in urls: url=line.rstrip() data=requests.get(url, proxies={'http':line}) data1=data.text print data1 and my urls.txt file: http://api.exip.org/?call=ip and my proxies.txt file: {"https": "84.22.41.1:3128"} {"http":"194.126.181.47:81"} {"http":"218.108.170.170:82"} that I got at [www.hidemyass.com][1] for

Http session synchronization between webview and java http client in Android

…衆ロ難τιáo~ 提交于 2019-12-04 18:45:00
I am developing hybrid application by using webview and native both. I am using ajax post method in my webview and also using post method via HttpClient on my default android code. But even if i go to same server my session id's doesn't match with each other. Is there any way to make http request within same session in my application? Thanks for any advice. I have solved this issue: public void syncSession(final Context ctx){ new Thread(new Runnable(){ public void run(){ //Products will be stated in memory ProductManager pm = ProductManager.getInstance(); // HttpClient httpclient = new

jsonParser.makeHttpRequest error in json parsing

感情迁移 提交于 2019-12-04 18:41:49
I try to parse data using json and AsyncTask . But am getting the error on these line: JSONObject json = jsonParser.makeHttpRequest(url_product_detials, "GET", params); this is my code: public class EditWatchListProducts extends Activity { EditText txtName; EditText txtPrice; Button btnSave; Button btnDelete; String pid; private ProgressDialog pDialog; JSONParser jsonParser = new JSONParser(); private static final String url_product_detials = "http://192.168.2.22/android_connect/get_product_details.php"; private static final String url_update_product = "http://192.168.2.22/android_connect

Add HEADER in HTTP Request in Java

泪湿孤枕 提交于 2019-12-04 16:40:34
I'm using this following code to send simple HTTP Request : try { Socket s = new Socket (); s.bind (new InetSocketAddress (ipFrom, 0)); s.connect (new InetSocketAddress (ipTo, 80), 1000); PrintWriter writer = new PrintWriter (s.getOutputStream ()); BufferedReader reader = new BufferedReader (new InputStreamReader (s.getInputStream ())); writer.print ("GET " + szUrl + " HTTP/1.0\r\n\r\n"); writer.flush (); s .close (); reader.close (); writer.close (); } However, as you can see, I don't send a custom HEADER. What should I add to send a custom HEADER ? Cheers, Christophe OLIVIER When you write