Record Class RecordedRequest
java.lang.Object
java.lang.Record
cloud.opencode.base.test.http.RecordedRequest
- Record Components:
method- the HTTP method - HTTP 方法path- the request path including query string - 包含查询字符串的请求路径headers- the request headers (lowercase keys) - 请求头(键为小写)body- the request body bytes - 请求体字节
public record RecordedRequest(String method, String path, Map<String,String> headers, byte[] body)
extends Record
Recorded HTTP Request — a snapshot of an HTTP request received by
TestHttpServer.
记录的 HTTP 请求 — 由 TestHttpServer 接收的 HTTP 请求快照。
Features | 主要功能:
- HTTP request snapshot capture - HTTP请求快照捕获
- Header and body access - 请求头和请求体访问
Usage Examples | 使用示例:
RecordedRequest req = server.recordedRequest("/api/users");
String body = req.bodyAsString();
String auth = req.header("Authorization");
Security | 安全性:
- Thread-safe: Yes (immutable) - 线程安全: 是(不可变)
- Since:
- JDK 25, opencode-base-test V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbyte[]body()Returns a defensive copy of the body bytes.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.headers()Returns the value of theheadersrecord component.method()Returns the value of themethodrecord component.path()Returns the value of thepathrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
RecordedRequest
-
-
Method Details
-
body
public byte[] body()Returns a defensive copy of the body bytes. 返回请求体字节的防御性副本。- Returns:
- body bytes copy | 请求体字节副本
-
bodyAsString
-
header
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
method
-
path
-
headers
-