Package | Description |
---|---|
cn.hutool.http.server |
Http服务器封装
|
cn.hutool.http.server.action |
HttpServer 封装 |
cn.hutool.http.server.filter |
Filter 实现包装 |
Modifier and Type | Method and Description |
---|---|
HttpServerResponse |
HttpServerResponse.addHeader(String header,
String value)
添加响应头,如果已经存在,则追加
|
HttpServerResponse |
HttpExchangeWrapper.getResponse()
获取响应
|
HttpServerResponse |
HttpServerResponse.send(int httpStatusCode)
发送HTTP状态码,Content-Length为0不定长度,会输出Transfer-encoding: chunked
|
HttpServerResponse |
HttpServerResponse.send(int httpStatusCode,
long bodyLength)
发送HTTP状态码
|
HttpServerResponse |
HttpServerResponse.send404(String content)
发送404错误页
|
HttpServerResponse |
HttpServerResponse.sendError(int errorCode,
String content)
发送错误页
|
HttpServerResponse |
HttpServerResponse.sendOk()
发送成功状态码
|
HttpServerResponse |
HttpServerResponse.sendOk(int bodyLength)
发送成功状态码
|
HttpServerResponse |
HttpServerResponse.setAttr(String name,
Object value)
设置属性
|
HttpServerResponse |
HttpServerResponse.setCharset(Charset charset)
设置响应的编码
|
HttpServerResponse |
HttpServerResponse.setContentLength(long contentLength)
设置Content-Length头
|
HttpServerResponse |
HttpServerResponse.setContentType(String contentType)
设置Content-Type头,类似于:text/html;charset=utf-8
如果用户传入的信息无charset信息,自动根据charset补充,charset设置见 setCharset(Charset) |
HttpServerResponse |
HttpServerResponse.setHeader(Header header,
String value)
设置响应头,如果已经存在,则覆盖
|
HttpServerResponse |
HttpServerResponse.setHeader(String header,
List<String> value)
设置响应头,如果已经存在,则覆盖
|
HttpServerResponse |
HttpServerResponse.setHeader(String header,
String value)
设置响应头,如果已经存在,则覆盖
|
HttpServerResponse |
HttpServerResponse.setHeaders(Map<String,List<String>> headers)
设置所有响应头,如果已经存在,则覆盖
|
HttpServerResponse |
HttpServerResponse.write(byte[] data)
写出数据到客户端
|
HttpServerResponse |
HttpServerResponse.write(byte[] data,
String contentType)
写出数据到客户端
|
HttpServerResponse |
HttpServerResponse.write(File file)
返回文件给客户端(文件下载)
|
HttpServerResponse |
HttpServerResponse.write(File file,
String fileName)
返回文件给客户端(文件下载)
|
HttpServerResponse |
HttpServerResponse.write(InputStream in)
写出数据到客户端
|
HttpServerResponse |
HttpServerResponse.write(InputStream in,
int length)
写出数据到客户端
|
HttpServerResponse |
HttpServerResponse.write(InputStream in,
int length,
String contentType)
返回数据给客户端
|
HttpServerResponse |
HttpServerResponse.write(InputStream in,
int length,
String contentType,
String fileName)
返回文件数据给客户端(文件下载)
|
HttpServerResponse |
HttpServerResponse.write(InputStream in,
String contentType)
返回数据给客户端
|
HttpServerResponse |
HttpServerResponse.write(String data)
写出数据到客户端
|
HttpServerResponse |
HttpServerResponse.write(String data,
String contentType)
写出数据到客户端
|
Modifier and Type | Method and Description |
---|---|
void |
RootAction.doAction(HttpServerRequest request,
HttpServerResponse response) |
void |
Action.doAction(HttpServerRequest request,
HttpServerResponse response)
处理请求
|
Modifier and Type | Method and Description |
---|---|
abstract void |
ExceptionFilter.afterException(HttpServerRequest req,
HttpServerResponse res,
Throwable e)
异常之后的处理逻辑
|
void |
DefaultExceptionFilter.afterException(HttpServerRequest req,
HttpServerResponse res,
Throwable e) |
void |
HttpFilter.doFilter(HttpServerRequest req,
HttpServerResponse res,
com.sun.net.httpserver.Filter.Chain chain)
执行过滤
|
void |
ExceptionFilter.doFilter(HttpServerRequest req,
HttpServerResponse res,
com.sun.net.httpserver.Filter.Chain chain) |
Copyright © 2024. All rights reserved.