Okhttp3Request
此章节待补充或完善...
Marked by SuperMonster003 on Mar 2, 2023.
okhttp3.Request 别名.
Okhttp3Request 表示一个 HTTP 请求.
js
let request = new okhttp3.Request.Builder()
.url('https://www.msn.com')
.method('GET', null)
.build();
// Request{method=GET, url=https://www.msn.com/}
console.log(request);常见相关方法或属性:
注: 本章节仅列出部分属性或方法.
okhttp3.Request
[m] body
body()
- returns { okhttp3.RequestBody | null }
获取 HTTP 请求的 "请求体 (Request Body)".
[m] cacheControl
cacheControl()
- returns { okhttp3.CacheControl }
获取 HTTP 请求标头字段 cache-control 的信息.
js
let cacheControl = http.get('https://www.msn.com', {
headers: {
'cache-control': 'no-transform, no-store, no-cache',
},
contentType: 'text/plain',
}).request.cacheControl();
console.log(cacheControl); // no-transform, no-store, no-cache
console.log(cacheControl.noTransform()); // true
console.log(cacheControl.noStore()); // true
console.log(cacheControl.mustRevalidate()); // false