MCPcopy Create free account
hub / github.com/0x676e67/wreq-python / execute_request

Function execute_request

src/client/opts.rs:60–183  ·  view source on GitHub ↗

Executes an HTTP request.

(
    client: Client,
    method: Method,
    url: U,
    mut params: Option<RequestParams>,
)

Source from the content-addressed store, hash-verified

58
59/// Executes an HTTP request.
60pub async fn execute_request<U>(
61 client: Client,
62 method: Method,
63 url: U,
64 mut params: Option<RequestParams>,
65) -> PyResult<Response>
66where
67 U: AsRef<str>,
68{
69 let params = params.get_or_insert_default();
70 let mut builder = client.request(method.into_ffi(), url.as_ref());
71
72 // Version options.
73 apply_option!(
74 apply_transformed_option,
75 builder,
76 params.version,
77 version,
78 Version::into_ffi
79 );
80
81 // Timeout options.
82 apply_option!(
83 apply_transformed_option,
84 builder,
85 params.timeout,
86 timeout,
87 Duration::from_secs
88 );
89 apply_option!(
90 apply_transformed_option,
91 builder,
92 params.read_timeout,
93 read_timeout,
94 Duration::from_secs
95 );
96
97 // Network options.
98 apply_option!(apply_if_some_inner, builder, params.proxy, proxy);
99 apply_option!(
100 apply_if_some_inner,
101 builder,
102 params.local_address,
103 local_address
104 );
105 #[cfg(any(
106 target_os = "android",
107 target_os = "fuchsia",
108 target_os = "linux",
109 target_os = "ios",
110 target_os = "visionos",
111 target_os = "macos",
112 target_os = "tvos",
113 target_os = "watchos"
114 ))]
115 apply_option!(apply_if_some, builder, params.interface, interface);
116
117 // Headers options.

Callers 3

shortcut_requestFunction · 0.85
requestMethod · 0.85
requestMethod · 0.85

Calls 2

requestMethod · 0.45
sendMethod · 0.45

Tested by

no test coverage detected