In the internship, the use of the HTTP connection, has been understood to be very vague, specifically to write an analysis of the article. Please advise me where the analysis is not in place.
HTTP is currently a generic version of HTTP 1.1.
HTTP connections are broadly divided into 2 common requests--get,post
I. Basic process (using httpclient)
get{
1. New HttpClient Object--HttpClient http = httpclients.createdefault ();
2. Create a GET request--httpget get = new HttpGet (url--interface address/request path);
3. Get the response--HttpResponse resp = Http.execute (get);
4. Get the response entity-- httpentity entity = resp.getentity ();
5. New Result object string--String result = entityutils.tostring (entity, "Utf-8");
6. Print-System.out.print ("The result is:" +result);
}
post{
1. New HttpClient Object--HttpClient http = httpclients.createdefault ();
2. Create POST request--httppost post = new HttpPost (url--interface address/request path);
3. Create a list container that holds the basic key-value pairs--{
list<basicnamevaluepair> params = new arraylist<> ();
Params.add (key value pair 1);
Params.add (key value pair 2);
}
4. Add the message entity--post.setentity (new urlencodedformentity (params, "utf-8") to the request;
5. Get the response-HttpResponse resp = Http.execute (post);
6. Get the response entity-- httpentity entity = resp.getentity ();
7. New Result Object-String result = entityutils.tostring (entity, "Utf-8");
8. Print-System.out.print ("The result is:" +result);
}
For the time being, it's such a thing.
Java Implementation HTTP connection (HTTPClient)