public class HttpResponse extends Object implements Result
HttpResponse.setContentPath(String) の値を設定することで後者の方式がとられるようになる。| 修飾子とタイプ | クラスと説明 |
|---|---|
static class |
HttpResponse.Status
HTTPレスポンスステータス。
|
Result.ClientError, Result.Error, Result.MultiStatus, Result.NotFound, Result.Success| コンストラクタと説明 |
|---|
HttpResponse()
HttpResponseオブジェクトを生成する。 |
HttpResponse(int statusCode)
指定されたステータスコードの
HttpResponseオブジェクトを生成する。 |
HttpResponse(int statusCode,
String contentPath)
指定されたHTTPステータスコードとコンテンツパスの
HttpResponseオブジェクトを生成する。 |
HttpResponse(String contentPath)
指定されたコンテンツパスの
HttpResponseオブジェクトを生成する。 |
| 修飾子とタイプ | メソッドと説明 |
|---|---|
HttpResponse |
addCookie(HttpCookie cookie)
サーバ側から送信されたクッキー情報を設定する。
|
InputStream |
getBodyStream()
HTTPレスポンスボディの内容を保持するストリームを取得する。
|
String |
getBodyString()
HTTPレスポンスボディの内容を表す文字列を返す。
|
String |
getContentDisposition()
Content-Dispositionの値を取得する。
|
String |
getContentLength()
Content-Lengthの値を取得する。
|
ResourceLocator |
getContentPath()
コンテンツパスを取得する。
|
String |
getContentType()
Content-Typeの値を取得する。
|
HttpCookie |
getCookie()
非推奨です。
本メソッドは、複数のクッキー情報のうち先頭のクッキーを返すことしかできません。
複数のクッキー情報を返すことができる
#getCookieList()を使用してください。 |
String |
getHeader(String headerName)
HTTPレスポンスヘッダの値を返す。
|
Map |
getHeaderMap()
HTTPレスポンスヘッダを格納するMapを返す。
|
String |
getHttpVersion()
HTTPバージョンを表す文字列を返す。
|
String |
getLocation()
Locationの値を取得する。
|
String |
getMessage()
処理結果に対する詳細情報を返す。
|
String |
getReasonPhrase()
HTTPレスポンスのステータスフレーズを返す。
|
int |
getStatusCode()
HTTPレスポンスのステータスコードの値を返す。
|
boolean |
isBodyEmpty()
HTTPレスポンスボディの内容が設定されていなければ
trueを返す。 |
HttpResponse |
setBodyStream(InputStream bodyStream)
HTTPレスポンスボディの内容を保持するストリームを設定する。
|
HttpResponse |
setContentDisposition(String fileName)
Content-Dispositionの値を設定する。
|
HttpResponse |
setContentDisposition(String fileName,
boolean inline)
Content-Dispositionの値を設定する。
|
HttpResponse |
setContentPath(ResourceLocator resource)
コンテンツパスを設定する。
|
HttpResponse |
setContentPath(String path)
コンテンツパスを設定する。
|
HttpResponse |
setContentType(String contentType)
Content-Typeを設定する。
|
HttpResponse |
setCookie(HttpCookie cookie)
非推奨です。
本メソッドは、複数のクッキー情報を設定することを意図したメソッド名を持つ
HttpResponse.addCookie(HttpCookie)に置き換わりました。 |
void |
setHeader(String headerName,
String value)
HTTPレスポンスヘッダの値を設定する。
|
HttpResponse |
setLocation(String location)
Locationの値を設定する。
|
HttpResponse |
setStatusCode(int code)
HTTPレスポンスのステータスコードを設定する。
|
HttpResponse |
write(byte[] bytes)
HTTPレスポンスボディにバイト配列を書き込む。
|
HttpResponse |
write(ByteBuffer bytes)
HTTPレスポンスボディにバイト配列を書き込む。
|
HttpResponse |
write(CharSequence text)
HTTPレスポンスボディに文字列を書き込む。
|
@Published public HttpResponse()
HttpResponseオブジェクトを生成する。
以下のHTTPレスポンスメッセージに相当するHttpResponseオブジェクトを生成する。
HTTP/1.1 200 OK
Content-Type: text/plain;charset=UTF-8
@Published public HttpResponse(int statusCode)
HttpResponseオブジェクトを生成する。
このメソッドの処理は以下のソースコードと等価である。
new HttpResponse().setStatusCode(statusCode);
statusCode - HTTPステータスコード@Published
public HttpResponse(int statusCode,
String contentPath)
HttpResponseオブジェクトを生成する。
このメソッドの処理は以下のソースコードと等価である。
new HttpResponse().setStatusCode(statusCode)
.setContentPath(contentPath);
statusCode - HTTPステータスコードcontentPath - コンテンツパス@Published public HttpResponse(String contentPath)
HttpResponseオブジェクトを生成する。
このメソッドの処理は以下のソースコードと等価である。
new HttpResponse().setStatusCode(200)
.setContentPath(contentPath);
contentPath - コンテンツパス@Published public int getStatusCode()
302を返す。getStatusCode インタフェース内 ResultHttpResponse.setStatusCode(int)@Published public HttpResponse setStatusCode(int code)
200である。code - HTTPステータスコードIllegalArgumentException - 指定されたステータスコードが無効な場合@Published public String getReasonPhrase()
@Published public String getMessage()
(ステータスコード): (ステータスフレーズ)
getMessage インタフェース内 Result@Published public String getHttpVersion()
@Published public Map getHeaderMap()
@Published public String getHeader(String headerName)
headerName - ヘッダー名@Published public void setHeader(String headerName, String value)
headerName - ヘッダー名value - ヘッダーの値@Published public String getContentType()
this.headers().get("Content-Type")
@Published public HttpResponse setContentType(String contentType)
contentType - Content-Typeの値HttpResponse.getContentType()@Published public String getLocation()
this.headers().get("Location")
@Published public HttpResponse setLocation(String location)
location - 遷移先URIHttpResponse.Status.SEE_OTHER@Published public HttpResponse setContentDisposition(String fileName)
fileName - ファイル名@Published public HttpResponse setContentDisposition(String fileName, boolean inline)
inlineにtrueを指定した場合、ダウンロードされたファイルは
クライアントアプリで自動的に開かれる。fileName - ファイル名inline - インライン表示する場合はtrue@Published(tag="architect") public String getContentDisposition()
@Published @Deprecated public HttpCookie getCookie()
#getCookieList()を使用してください。null@Published @Deprecated public HttpResponse setCookie(HttpCookie cookie)
HttpResponse.addCookie(HttpCookie)に置き換わりました。cookie - クッキー情報オブジェクト@Published public HttpResponse addCookie(HttpCookie cookie)
cookie - クッキー情報オブジェクト@Published public HttpResponse setContentPath(String path)
HttpResponse.setContentPath(ResourceLocator)に委譲する。path - コンテンツパス@Published public HttpResponse setContentPath(ResourceLocator resource)
ResourceLocatorオブジェクトがnullでない場合は、
リソース名からContent-Typeを自動的に設定した後、コンテンツパスを設定する。ResourceLocatorオブジェクトがnullの場合は、コンテンツパスのみ設定する。resource - コンテンツパスHttpResponse.setContentPath(String)@Published public ResourceLocator getContentPath()
@Published public String getContentLength()
nullを返す。@Published(tag="architect") public boolean isBodyEmpty()
trueを返す。true@Published(tag="architect") public String getBodyString()
@Published(tag="architect") public InputStream getBodyStream()
@Published(tag="architect") public HttpResponse setBodyStream(InputStream bodyStream)
bodyStream - HTTPレスポンスボディの内容を保持するストリーム@Published public HttpResponse write(CharSequence text) throws HttpErrorResponse
nablarch.fw.web.handler.HttpResponseHandlerにレスポンスオブジェクトが戻された後である。
また、このオブジェクトにコンテンツパスが設定されている場合、
このライタに書き込まれた内容は単に無視される。text - 書き込む文字列HttpErrorResponse - バッファの上限を越えてデータが書き込まれた場合@Published public HttpResponse write(byte[] bytes) throws HttpErrorResponse
nablarch.fw.web.handler.HttpResponseHandlerにレスポンスオブジェクトが戻された後である。
また、このオブジェクトにコンテンツパスが設定されている場合、
このライタに書き込まれた内容は単に無視される。bytes - 書き込むバイト配列HttpErrorResponse - バッファの上限を越えてデータが書き込まれた場合@Published public HttpResponse write(ByteBuffer bytes) throws HttpErrorResponse
nablarch.fw.web.handler.HttpResponseHandlerにレスポンスオブジェクトが戻された後である。
また、このオブジェクトにコンテンツパスが設定されている場合、
このライタに書き込まれた内容は単に無視される。bytes - 書き込むバイト列を格納したバッファHttpErrorResponse - バッファの上限を越えてデータが書き込まれた場合