Problems

Use the following problems to test your HTTP Client and WebSocket API programming prowess. I strongly encourage you to give each problem a try before you turn to the solutions and download the example programs:

  1. HTTP/2: Provide a brief overview of the HTTP/2 protocol
  2. Triggering an asynchronous GET request: Write a program that uses the HTTP Client API to trigger an asynchronous GET request and display the response code and body.
  3. Setting a proxy: Write a program that uses the HTTP Client API to set up a connection via a proxy.
  4. Setting/getting headers: Write a program that adds additional headers to the request and gets the headers of the response.
  1. Specifying the HTTP method: Write a program that specifies the HTTP method of a request (for example, GET, POST, PUT, and DELETE).
  2. Setting the request body: Write a program that uses the HTTP Client API to add a body to a request.
  3. Setting connection authentication: Write a program that uses the HTTP Client API to set up a connection authentication via username and password.
  4. Setting a timeout: Write a program that uses the HTTP Client API to set the amount of time we want to wait for a response (timeout).
  5. Setting the redirect policy: Write a program that uses the HTTP Client API to automatically redirect if needed.
  6. Sending sync and async requests: Write a program that sends the same request in sync and async modes.
  7. Handling cookies: Write a program that uses the HTTP Client API to set a cookie handler.
  8. Getting response information: Write a program that uses the HTTP Client API to get information about the response (for example, URI, version, headers, status code, body, and so on).
  9. Handling response body types: Write several snippets of code to exemplify how to handle common response body types via HttpResponse.BodyHandlers.
  10. Getting, updating, and saving a JSON: Write a program that uses the HTTP Client API to get, update, and save a JSON.
  11. Compression: Write a program that handles compressed responses (for example, .gzip).
  12. Handling form data: Write a program that uses the HTTP Client API to submit a data form (application/x-www-form-urlencoded).
  13. Downloading a resource: Write a program that uses the HTTP Client API to download a resource.
  14. Uploading with multipart: Write a program that uses the HTTP Client API to upload a resource.
  15. HTTP/2 server push: Write a program that exemplifies the HTTP/2 server push feature via the HTTP Client API.
  16. WebSocket: Write a program that opens a connection to a WebSocket endpoint, collects data for 10 seconds, and closes the connection.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.223.206.69