MCPcopy Create free account
hub / github.com/chatmail/core / http_cache_put

Function http_cache_put

src/net/http.rs:155–177  ·  view source on GitHub ↗

Places the binary into HTTP cache.

(context: &Context, url: &str, response: &Response)

Source from the content-addressed store, hash-verified

153
154/// Places the binary into HTTP cache.
155async fn http_cache_put(context: &Context, url: &str, response: &Response) -> Result<()> {
156 let blob =
157 BlobObject::create_and_deduplicate_from_bytes(context, response.blob.as_slice(), "")?;
158
159 let (expires, stale) = http_url_cache_timestamps(url, response.mimetype.as_deref());
160 context
161 .sql
162 .insert(
163 "INSERT OR REPLACE INTO http_cache (url, expires, stale, blobname, mimetype, encoding)
164 VALUES (?, ?, ?, ?, ?, ?)",
165 (
166 url,
167 expires,
168 stale,
169 blob.as_name(),
170 response.mimetype.as_deref().unwrap_or_default(),
171 response.encoding.as_deref().unwrap_or_default(),
172 ),
173 )
174 .await?;
175
176 Ok(())
177}
178
179/// Retrieves the binary from HTTP cache.
180///

Callers 2

fetch_urlFunction · 0.85
test_http_cacheFunction · 0.85

Calls 3

insertMethod · 0.80
as_nameMethod · 0.80

Tested by 1

test_http_cacheFunction · 0.68