api_struct
api_struct copied to clipboard
Timeout
Is there a way of passing a timeout option (open_timeout, read_timeout, write_timeout) to the http methods?
This wasn't easy so I will share it in case anyone else is struggling with it. You can pass the timeout_options
like this if you want a timeout per operation (there is a global timeout as well but I haven't used it):
get('test', headers: request_headers, timeout_class: HTTP::Timeout::PerOperation, timeout_options: {read_timeout: TIMEOUT_VALUE, write_timeout: TIMEOUT_VALUE})
You can also configure connect_timeout