/src/ostree/src/libostree/ostree-fetcher-util.h
Line | Count | Source |
1 | | /* |
2 | | * Copyright (C) 2016 Colin Walters <walters@verbum.org> |
3 | | * |
4 | | * SPDX-License-Identifier: LGPL-2.0+ |
5 | | * |
6 | | * This library is free software; you can redistribute it and/or |
7 | | * modify it under the terms of the GNU Lesser General Public |
8 | | * License as published by the Free Software Foundation; either |
9 | | * version 2 of the License, or (at your option) any later version. |
10 | | * |
11 | | * This library is distributed in the hope that it will be useful, |
12 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | | * Lesser General Public License for more details. |
15 | | * |
16 | | * You should have received a copy of the GNU Lesser General Public |
17 | | * License along with this library. If not, see <https://www.gnu.org/licenses/>. |
18 | | */ |
19 | | |
20 | | #pragma once |
21 | | |
22 | | #ifndef __GI_SCANNER__ |
23 | | |
24 | | #include "ostree-fetcher.h" |
25 | | |
26 | | G_BEGIN_DECLS |
27 | | |
28 | | /* We used to only send "ostree/" but now include the version |
29 | | * https://github.com/ostreedev/ostree/issues/1405 |
30 | | * This came up in allowing Fedora infrastructure to work around a libcurl bug with HTTP2. |
31 | | */ |
32 | | #define OSTREE_FETCHER_USERAGENT_STRING (PACKAGE_NAME "/" PACKAGE_VERSION) |
33 | | |
34 | | static inline gboolean |
35 | | _ostree_fetcher_tmpf (int dfd, GLnxTmpfile *tmpf, GError **error) |
36 | 0 | { |
37 | 0 | if (!glnx_open_tmpfile_linkable_at (dfd, ".", O_RDWR | O_CLOEXEC, tmpf, error)) |
38 | 0 | return FALSE; |
39 | 0 | if (!glnx_fchmod (tmpf->fd, 0644, error)) |
40 | 0 | return FALSE; |
41 | 0 | return TRUE; |
42 | 0 | } |
43 | | |
44 | | gboolean _ostree_fetcher_mirrored_request_to_membuf ( |
45 | | OstreeFetcher *fetcher, GPtrArray *mirrorlist, const char *filename, |
46 | | OstreeFetcherRequestFlags flags, const char *if_none_match, guint64 if_modified_since, |
47 | | guint n_network_retries, GBytes **out_contents, gboolean *out_not_modified, char **out_etag, |
48 | | guint64 *out_last_modified, guint64 max_size, GCancellable *cancellable, GError **error); |
49 | | |
50 | | gboolean _ostree_fetcher_request_uri_to_membuf ( |
51 | | OstreeFetcher *fetcher, OstreeFetcherURI *uri, OstreeFetcherRequestFlags flags, |
52 | | const char *if_none_match, guint64 if_modified_since, guint n_network_retries, |
53 | | GBytes **out_contents, gboolean *out_not_modified, char **out_etag, guint64 *out_last_modified, |
54 | | guint64 max_size, GCancellable *cancellable, GError **error); |
55 | | |
56 | | void _ostree_fetcher_journal_failure (const char *remote_name, const char *url, const char *msg); |
57 | | |
58 | | gboolean _ostree_fetcher_should_retry_request (const GError *error, guint n_retries_remaining); |
59 | | |
60 | | GIOErrorEnum _ostree_fetcher_http_status_code_to_io_error (guint status_code, gboolean retry_all); |
61 | | |
62 | | G_END_DECLS |
63 | | |
64 | | #endif |