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:
- HTTP/2: Provide a brief overview of the HTTP/2 protocol
- 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.
- Setting a proxy: Write a program that uses the HTTP Client API to set up a connection via a proxy.
- Setting/getting headers: Write a program that adds additional headers to the request and gets the headers of the response.
- Specifying the HTTP method: Write a program that specifies the HTTP method of a request (for example, GET, POST, PUT, and DELETE).
- Setting the request body: Write a program that uses the HTTP Client API to add a body to a request.
- Setting connection authentication: Write a program that uses the HTTP Client API to set up a connection authentication via username and password.
- 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).
- Setting the redirect policy: Write a program that uses the HTTP Client API to automatically redirect if needed.
- Sending sync and async requests: Write a program that sends the same request in sync and async modes.
- Handling cookies: Write a program that uses the HTTP Client API to set a cookie handler.
- 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).
- Handling response body types: Write several snippets of code to exemplify how to handle common response body types via HttpResponse.BodyHandlers.
- Getting, updating, and saving a JSON: Write a program that uses the HTTP Client API to get, update, and save a JSON.
- Compression: Write a program that handles compressed responses (for example, .gzip).
- Handling form data: Write a program that uses the HTTP Client API to submit a data form (application/x-www-form-urlencoded).
- Downloading a resource: Write a program that uses the HTTP Client API to download a resource.
- Uploading with multipart: Write a program that uses the HTTP Client API to upload a resource.
- HTTP/2 server push: Write a program that exemplifies the HTTP/2 server push feature via the HTTP Client API.
- WebSocket: Write a program that opens a connection to a WebSocket endpoint, collects data for 10 seconds, and closes the connection.