public class Client extends Caller
Chain.Buffer, Chain.Reader| Modifier and Type | Field and Description |
|---|---|
protected int |
code |
protected HttpURLConnection |
conn |
bucket, count, EMPTY_BYTES, EMPTY_CHARS, hash, type, value| Constructor and Description |
|---|
Client(@NotNull HttpURLConnection conn) |
Client(@NotNull String url) |
Client(@NotNull String url,
@NotNull Proxy proxy) |
Client(@NotNull URL url) |
Client(@NotNull URLConnection conn) |
Client(@NotNull URL url,
@NotNull Proxy proxy) |
| Modifier and Type | Method and Description |
|---|---|
Client |
accept(@NotNull Job job)
Sets the request property of
Accept |
Client |
accept(@Nullable String value)
Sets the request property of
Accept |
Client |
agent(@Nullable String value)
Sets the request property of
User-Agent |
Client |
cache(boolean status)
Sets the value of the
useCaches field |
protected void |
check(byte[] d,
int i,
int l)
Check Bounds
|
int |
code()
Returns the code of
status |
@Nullable String |
contentType()
Returns the value of the
Content-Type header field |
Client |
contentType(@NotNull Job job)
Sets the request property of
Content-Type |
Client |
contentType(@Nullable String value)
Sets the request property of
Content-Type |
Client |
delete()
new Client("https://kat.plus/test/del-user").delete();
|
Client |
get()
String url = "https://kat.plus/test/user.json";
User user = new Client(url).get().to(User.class);
|
@Nullable String |
head(int n)
Returns the value for the
nth header field |
@Nullable String |
head(@NotNull String key)
Returns the value of the named header field
|
String |
header(@NotNull String key)
Returns the value of the named general request property for this connection
|
Client |
header(@NotNull String key,
@Nullable Object value)
Sets the general request property
|
Client |
header(@NotNull String key,
@Nullable String value)
Sets the general request property
|
boolean |
isClientError()
Returns
true if and only if code in [400,500) |
boolean |
isError()
Returns
true if and only if code in [400,600) |
boolean |
isInfo()
Returns
true if and only if code in [100,200) |
boolean |
isRedirect()
Returns
true if and only if code in [300,400) |
boolean |
isServerError()
Returns
true if and only if code in [500,600) |
boolean |
isSuccess()
Returns
true if and only if code in [200,300) |
@NotNull Job |
job()
Returns the specified
Job |
Client |
post(byte[] data) |
Client |
post(byte[] data,
int i,
int l) |
Client |
post(Chan chan)
String url = "https://kat.plus/test/add-user";
Chan chan = ...;
User user = new Client(url).post(chan).to(User.class);
|
Client |
post(Paper flow) |
Client |
post(String data)
String url = "https://kat.plus/test/add-user";
String data = "{:id(1):name(kraity)}";
User user = new Client(url).post(data).to(User.class);
|
Client |
put(byte[] data) |
Client |
put(byte[] data,
int i,
int l) |
Client |
put(Chan chan) |
Client |
put(Paper flow) |
Client |
put(String data)
String url = "https://kat.plus/test/add-user";
String data = "{:id(1):name(kraity)}";
User user = new Client(url).put(data).to(User.class);
|
Client |
readout(int timeout)
Sets a specified read timeout value, in milliseconds
|
Client |
redirect(boolean status)
Sets whether HTTP redirects (code 3xx) should be automatically followed
|
Client |
referer(@Nullable String value)
Sets the request property of
Referer |
protected Client |
request(String method,
byte[] data,
int i,
int l) |
protected Client |
request(String method,
Chain chain) |
protected void |
resolve(@NotNull URLConnection conn) |
Client |
timeout(int timeout)
Sets a specified connect timeout value, in milliseconds
|
Client |
view()
new Client("https://kat.plus/test/user").view();
|
getJob, getSupplier, solve, stream, subSequence, to, to, to, with, with, withat, byteAt, capacity, chain, chain, chain, chain, chain, chain, chain, chain, charAt, clean, clear, close, compareTo, contains, contains, contains, copyBytes, copyBytes, copyChars, copyChars, digest, digest, digest, doFinal, doFinal, endsWith, equals, fromBase, fromMime, fromSafe, get, get, getBytes, getBytes, getType, getValue, grow, hashCode, head, head, indexOf, indexOf, indexOf, indexOf, indexOf, indexOf, is, is, is, is, is, is, isBlank, isEmpty, isNotBlank, isNotEmpty, isShared, isSole, lastIndexOf, lastIndexOf, lastIndexOf, lastIndexOf, lastIndexOf, lastIndexOf, length, reader, reader, setType, sole, startWith, string, string, string, swop, tail, tail, toBase, toBase64, toBoolean, toBoolean, toChar, toChar, toDouble, toDouble, toFloat, toFloat, toInt, toInt, toInt, toLong, toLong, toLong, toMime, toMime64, toNumber, toNumber, toSafe, toSafe64, toString, toString, toString, toString, update, update, update, update, update, update, update, update, update, updateclone, finalize, getClass, notify, notifyAll, wait, wait, waitchars, codePointsprotected int code
protected HttpURLConnection conn
public Client(@NotNull @NotNull String url) throws IOException
url - the url to parse as a URLIOException - If an I/O error occursMalformedURLException - If no protocol is specified, or an unknown protocol is found, or spec is nullpublic Client(@NotNull @NotNull URL url) throws IOException
IOException - If an I/O error occurspublic Client(@NotNull @NotNull URL url, @NotNull @NotNull Proxy proxy) throws IOException
proxy - the specified proxyIOException - If an I/O error occurspublic Client(@NotNull @NotNull String url, @NotNull @NotNull Proxy proxy) throws IOException
url - the url to parse as a URLproxy - the specified proxyIOException - If an I/O error occursMalformedURLException - If no protocol is specified, or an unknown protocol is found, or spec is nullpublic Client(@NotNull @NotNull URLConnection conn) throws IOException
conn - the specified URLConnectionIOException - If an I/O error occursUnexpectedCrash - If the conn is not HttpURLConnectionpublic Client(@NotNull @NotNull HttpURLConnection conn) throws IOException
conn - the specified HttpURLConnectionIOException - If an I/O error occursUnexpectedCrash - If the conn is nullpublic int code()
status@Nullable public @Nullable String head(int n)
nth header fieldn - an index, where n>=0String or nullHttpURLConnection.getHeaderField(int)@Nullable public @Nullable String head(@NotNull @NotNull String key)
key - the name of a header fieldString or nullURLConnection.getHeaderField(String)public Client readout(int timeout)
URLConnection.setReadTimeout(int)public Client timeout(int timeout)
URLConnection.setConnectTimeout(int)public Client cache(boolean status)
useCaches fieldURLConnection.setUseCaches(boolean)public Client redirect(boolean status)
public Client referer(@Nullable @Nullable String value)
Refererpublic String header(@NotNull @NotNull String key)
String or nullURLConnection.getRequestProperty(String)public Client header(@NotNull @NotNull String key, @Nullable @Nullable String value)
public Client header(@NotNull @NotNull String key, @Nullable @Nullable Object value)
public Client accept(@NotNull @NotNull Job job)
Acceptaccept(String)@Nullable public @Nullable String contentType()
Content-Type header fieldString or nullURLConnection.getHeaderField(String)public Client contentType(@Nullable @Nullable String value)
Content-Typepublic Client contentType(@NotNull @NotNull Job job)
Content-TypecontentType(String)public boolean isInfo()
true if and only if code in [100,200)public boolean isSuccess()
true if and only if code in [200,300)public boolean isRedirect()
true if and only if code in [300,400)public boolean isError()
true if and only if code in [400,600)public boolean isClientError()
true if and only if code in [400,500)public boolean isServerError()
true if and only if code in [500,600)public Client get() throws IOException
String url = "https://kat.plus/test/user.json";
User user = new Client(url).get().to(User.class);
IOException - If an I/O error occurspublic Client view() throws IOException
new Client("https://kat.plus/test/user").view();
IOException - If an I/O error occurspublic Client delete() throws IOException
new Client("https://kat.plus/test/del-user").delete();
IOException - If an I/O error occurspublic Client put(String data) throws IOException
String url = "https://kat.plus/test/add-user";
String data = "{:id(1):name(kraity)}";
User user = new Client(url).put(data).to(User.class);
data - the specified contentIOException - If an I/O error occursNullPointerException - If the data is nullpublic Client put(byte[] data) throws IOException
data - the specified contentIOException - If an I/O error occurspublic Client put(byte[] data, int i, int l) throws IOException
data - the specified contentIOException - If an I/O error occurspublic Client put(Chan chan) throws IOException
chan - the specified chanIOException - If an I/O error occurspublic Client put(Paper flow) throws IOException
flow - the specified paperIOException - If an I/O error occurspublic Client post(String data) throws IOException
String url = "https://kat.plus/test/add-user";
String data = "{:id(1):name(kraity)}";
User user = new Client(url).post(data).to(User.class);
data - the specified contentIOException - If an I/O error occursNullPointerException - If the data is nullpublic Client post(Chan chan) throws IOException
String url = "https://kat.plus/test/add-user";
Chan chan = ...;
User user = new Client(url).post(chan).to(User.class);
chan - the specified chanIOException - If an I/O error occurspublic Client post(Paper flow) throws IOException
flow - the specified paperIOException - If an I/O error occurspublic Client post(byte[] data) throws IOException
data - the specified contentIOException - If an I/O error occurspublic Client post(byte[] data, int i, int l) throws IOException
data - the specified contentIOException - If an I/O error occursprotected void check(byte[] d,
int i,
int l)
protected void resolve(@NotNull @NotNull URLConnection conn) throws IOException
conn - the specified URLConnectionIOException - If an I/O error occursprotected Client request(String method, Chain chain) throws IOException
method - the specified methodchain - the specified chainIOException - If an I/O error occursprotected Client request(String method, byte[] data, int i, int l) throws IOException
method - the specified methoddata - the specified contentIOException - If an I/O error occursCopyright © 2022 Kat+ Team. All rights reserved.