public class Connection extends Object implements Closeable
| Constructor and Description |
|---|
Connection(URL url)
Make sure to wrap with a try-with-resource to ensure that the connection is closed after usage.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
Response |
get(Request request)
Sends the request with method GET.
|
Response |
post(Request request)
Sends the request with method POST.
|
Response |
put(Request request)
Sends the request with method PUT.
|
Response |
send(String httpMethod,
Request request)
Sends the request.
|
public Connection(URL url)
url - the url to send the request topublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionpublic Response get(Request request) throws IOException
request - the request to sendIOException - if sending the request failspublic Response post(Request request) throws IOException
request - the request to sendIOException - if sending the request failspublic Response put(Request request) throws IOException
request - the request to sendIOException - if sending the request failspublic Response send(String httpMethod, Request request) throws IOException
httpMethod - the HTTP request methodrequest - the request to sendIOException - if building the HTTP request fails.Copyright © 2018. All rights reserved.