huangcm
2025-08-30 0269911b91ed7e03c24005924cc6423abf245fb8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
 
library fuchsia.net.oldhttp;
 
// Specify the cache behavior of the request.
enum CacheMode {
  // Default behavior.
  DEFAULT = 0;
 
  // The HTTP request will bypass the local cache and will have a
  // 'Cache-Control: nocache' header added in that causes any proxy servers
  // to also not satisfy the request from their cache.  This has the effect
  // of forcing a full end-to-end fetch.
  BYPASS_CACHE = 1;
 
  // The HTTP request will fail if it cannot serve the requested resource
  // from the cache (or some equivalent local store).
  ONLY_FROM_CACHE = 2;
};
 
// Specify the mechanism used to return the response body.
enum ResponseBodyMode {
  // The complete response body should be returned in the |buffer| field of
  // the response body.
  BUFFER = 0;
  // The response body should be streamed through the |stream| field of the
  // response body.
  STREAM = 1;
  // The response body may be returned as a buffer or stream.
  BUFFER_OR_STREAM = 2;
};
 
struct URLRequest {
  // The URL to load.
  string url;
 
  // The HTTP method if applicable.
  string method = "GET";
 
  // Additional HTTP request headers.
  vector<HttpHeader>? headers;
 
  // The payload for the request body. For HTTP requests, the method must be set
  // to "POST" or "PUT". If a buffer is used for the body, a Content-Length
  // header will automatically be added.
  URLBody? body;
 
  // The buffer size of the socket returned in URLResponse's |body| member.
  // A value of 0 indicates that the default buffer size should be used.  This
  // value is just a suggestion. The URLLoader may choose to ignore this value.
  uint32 response_body_buffer_size = 0;
 
  // If set to true, then redirects will be automatically followed. Otherwise,
  // when a redirect is encounterd, FollowRedirect must be called to proceed.
  bool auto_follow_redirects = false;
 
  // The cache behavior for the request.
  CacheMode cache_mode = DEFAULT;
 
  // The response body mode.
  ResponseBodyMode response_body_mode = STREAM;
};