Complex requests
NeoCurl supports sending complex requests via python's keyword arguments.
Send
Breakdown
Here is a breakdown of keyword args supported by nc.Client.send:
-
method: nc.MethodHTTP request method. Type is an enum defined in
neocurlmodule.nc.Method.Getornc.GETnc.Method.Headornc.HEADnc.Method.Postornc.POSTnc.Method.Putornc.POSTnc.Method.Deleteornc.DELETEnc.Method.Patchornc.PATCH
-
body: None | str | bytesBody of the request. NeoCurl tries to parse it as
str, on fails attempts to parse abytes. Can beNoneto disable body. -
timeout: None | intRequest timeout in milliseconds. Default is
100s. -
headers: None | DictRequest headers. Parsed as a dictionary, can be
None. Example:headers = { "Content-Type": "binary/octet-stream", "User-Agent": "Neocurl/2.0.0-alpha.2", } -
params: None | DictQuery params. Parsed the same as
headers, can beNone.
Example
response = client.send(
"https://httpbin.org/post",
method = nc.POST,
timeout = 10_000,
headers = {
"Content-Type": "binary/octet-stream",
"User-Agent": "Neocurl/2.0.0-alpha.2",
},
params = {
"id": "20438",
},
)
Get and Post
nc.Client has two more methods: .get() and .post().
These dont need method specified.
Return
Functions return nc.Response.