pub struct Request<'body> { /* private fields */ }
Expand description

Represent an unsent query.

Calling send actually makes the request.

Implementations

Create a request for a specific HTTP method and Url

create a GET request

You may then use the builder-pattern to configure the request and then call send() to begin it

create a POST request

You should specify a payload to send with body() or set_body(), which will be read before the request turns into a Response.

create a PUT request

You should specify a payload to send with body() or set_body(), which will be read before the request turns into a Response.

set the HTTP Content-Length header

This is the number of bytes expected to be read by body().

If specified, the value is sent as the Content-Length header.

It does not matter to curl if you specify the wrong value, but the server may object.

set the HTTP Content-Length header

This is the number of bytes expected to be read by body().

If specified, the value is sent as the Content-Length header. Either way, curl will use Transfer-Encoding: chunked.

It does not matter to curl if you specify the wrong value, but the server may object.

Add one HTTP header to the request.

Any values may be sent, even those that may be invalid according to the HTTP specification. You should prefer to use the Header constants in the idcurl::Header module.

Sets the reader which the payload to send is read from

The entire body is read before send() completes.

The body is not read for the GET and DELETE methods.

The specified body, if a reference, must outlive this Request.

Sets the reader which the payload to send is read from

The entire body is read before send() completes.

The body is not read for the GET and DELETE methods.

The returned Request has the lifetime of your Read, because the body you intend to send needs to outlive the Request. You can either give a reference with a reader (example: Cursor::new(&my_vector_object)) or you can give ownership (Cursor::new(owned_vector)).

Make the HTTP request.

The configured request is sent along with its headers, then if specified, the body is sent if the Method is appropriate.

The function succeeds and you get a Response if the server could be contacted and an HTTP session was initiated.

You should then call Response::status().is_success() to check for an HTTP status code in the 200 range.

sets the number of redirects that will be followed

The default is 10. An error will be returned if the number is exceeded.

Specify None to disable handling redirects. A redirect is not an error, instead you will get a Response for the redirect response.

sets the number of redirects that will be followed

The default is 10. An error will be returned if the number is exceeded.

Specify None to disable handling redirects. A redirect is not an error, instead you will get a Response for the redirect response.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.