一款简单易用的基础网络通讯组件库。

HttpResponse 类

Http响应

Definition

命名空间: TouchSocket.Http
程序集: TouchSocket.Http (在 TouchSocket.Http.dll 中) 版本:4.0.0-beta.143+5fcca7a4e70968794985dc3793adc50531308be6
C#
public abstract class HttpResponse : HttpBase
Inheritance
Object    HttpBase    HttpResponse

属性

Accept 可接受MIME类型
(继承自 HttpBase。)
AcceptEncoding 允许编码
(继承自 HttpBase。)
Content 获取或设置HTTP内容。
(继承自 HttpBase。)
ContentLength 内容长度
(继承自 HttpBase。)
ContentStatus 内容填充完成状态
(继承自 HttpBase。)
ContentType 内容类型
(继承自 HttpBase。)
Headers 请求头集合
(继承自 HttpBase。)
IsChunk 是否分块
IsProxyAuthenticationRequired 是否代理权限验证。
IsRedirect 是否重定向
IsServer 是否在Server端工作
(重写 HttpBaseIsServer)
Protocols 协议名称,默认HTTP
(继承自 HttpBase。)
ProtocolVersion HTTP协议版本,默认1.1
(继承自 HttpBase。)
Responsed 是否已经响应数据。
StatusCode 状态码,默认200
StatusMessage 状态消息,默认Success

方法

AnswerAsync 构建数据并回应。

该方法仅在具有Client实例时有效。

CompleteChunkAsync 当传输模式是Chunk时,用于结束传输。
EqualsDetermines whether the specified object is equal to the current object.
(继承自 Object。)
FinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(继承自 Object。)
GetContentAsync 获取一次性内容。
(继承自 HttpBase。)
GetHashCodeServes as the default hash function.
(继承自 Object。)
GetTypeGets the Type of the current instance.
(继承自 Object。)
MemberwiseCloneCreates a shallow copy of the current Object.
(继承自 Object。)
ReadAsync 异步读取HTTP块段的内容。
(继承自 HttpBase。)
ReadCopyToAsync(Stream, CancellationToken) 异步读取并复制流数据
(继承自 HttpBase。)
ReadCopyToAsync(Stream, HttpFlowOperator) 异步读取并复制流数据
(继承自 HttpBase。)
ReadRequestLine 读取请求行。
(重写 HttpBaseReadRequestLine(ReadOnlySpanByte))
Reset
(重写 HttpBaseReset)
ToStringReturns a string that represents the current object.
(继承自 Object。)
WriteAsync 异步写入指定的只读内存数据。

扩展方法

FromFileAsync 从文件响应。

当response支持持续写入时,会直接回复响应。并阻塞执行,直到完成。所以在执行该方法之前,请确保已设置完成所有状态字

当response不支持持续写入时,会填充Content,且不会响应,需要自己执行Build,并发送。


(由 HttpExtensions 定义。)
FromFileAsync 从文件响应。

当response支持持续写入时,会直接回复响应。并阻塞执行,直到完成。所以在执行该方法之前,请确保已设置完成所有状态字

当response不支持持续写入时,会填充Content,且不会响应,需要自己执行Build,并发送。


(由 HttpExtensions 定义。)
GetBodyAsync 异步获取utf8编码的 HTTP 请求的主体内容。
(由 HttpExtensions 定义。)
GetBodyAsync 异步获取 HTTP 请求的主体内容。
(由 HttpExtensions 定义。)
GetBoundary 当数据类型为multipart/form-data时,获取boundary
(由 HttpExtensions 定义。)
Map 将源对象的属性映射到目标对象的属性中。
(由 Mapper 定义。)
Map 将源对象映射到目标类型的实例。
(由 Mapper 定义。)
MapTTarget 将源对象映射到指定目标类型的新实例。
(由 Mapper 定义。)
ToJsonString 转换为Json
(由 SerializeConvert 定义。)

参见