http: a way to send a write that must not be applied twice
A POST that failed in transport -- including a timeout while waiting for the answer -- is resent today, and so is one that got a 502 or 504. For a write such as Email/import the server may already have applied the first copy, so the resend can create a duplicate. post_json_once and Request::send_once send it once: a transport failure or a gateway error comes back to the caller, which can check the target before trying again. 429 and 503, which mean the request was not processed, are still retried.
This commit is contained in:
@@ -131,6 +131,14 @@ impl Request {
|
||||
let value = client.post_json(api_url, &self.envelope()?)?;
|
||||
Response::parse(value)
|
||||
}
|
||||
|
||||
/// As `send`, for a write that must not be applied twice: a transport
|
||||
/// failure comes back as an error instead of being resent (see
|
||||
/// `HttpClient::post_json_once`).
|
||||
pub fn send_once(&self, client: &HttpClient, api_url: &str) -> Result<Response, JmapError> {
|
||||
let value = client.post_json_once(api_url, &self.envelope()?)?;
|
||||
Response::parse(value)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
|
||||
Reference in New Issue
Block a user