public class HTTPResponse extends Object implements AutoCloseable
Modifier and Type | Class and Description |
---|---|
static class |
HTTPResponse.RequestStatus
リクエストのステータスを表す列挙型です。
|
Constructor and Description |
---|
HTTPResponse() |
Modifier and Type | Method and Description |
---|---|
void |
close()
このクラスを破棄します。
|
static HTTPResponse |
error(@NotNull RequestContext request,
@NotNull HTTPResponse.RequestStatus status)
エラーのレスポンスを生成します。
|
com.google.gson.JsonElement |
getAsJson()
レスポンスボディを JSON として取得します。
|
<T> T |
getAsObject(Class<T> clazz)
レスポンスボディをオブジェクトとして取得します。
|
String |
getAsString()
レスポンスボディを文字列として取得します。
|
@Nullable String |
getHeader(@NotNull String header)
ヘッダーを取得します。
ヘッダー名は大文字小文字を区別しません。
|
boolean |
isClientError()
クライアントエラーのレスポンスかどうかを取得します。
|
boolean |
isError()
エラーのレスポンスかどうかを取得します。
|
boolean |
isOK()
OK のレスポンスかどうかを取得します。
|
boolean |
isRedirect()
リダイレクトのレスポンスかどうかを取得します。
|
boolean |
isServerError()
サーバエラーのレスポンスかどうかを取得します。
|
boolean |
isSuccessful()
リクエストに成功したかどうかを取得します。
|
public static HTTPResponse error(@NotNull @NotNull RequestContext request, @NotNull @NotNull HTTPResponse.RequestStatus status)
request
- リクエストstatus
- ステータスpublic String getAsString()
public com.google.gson.JsonElement getAsJson()
public <T> T getAsObject(Class<T> clazz)
T
- クラスの型clazz
- クラスpublic void close() throws IOException
close
in interface AutoCloseable
IOException
- I/O エラーが発生した場合@Nullable public @Nullable String getHeader(@NotNull @NotNull String header)
header
- ヘッダー名public boolean isSuccessful()
public boolean isRedirect()
public boolean isClientError()
public boolean isServerError()
public boolean isError()
isClientError()
,
isServerError()
public boolean isOK()
Copyright © 2023. All rights reserved.