summaryrefslogtreecommitdiff
path: root/usr.sbin/rpki-client
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2021-04-08 16:47:00 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2021-04-08 16:47:00 +0000
commitaa49ef14186d4009170966ad74e1c6ea35c4920b (patch)
tree2d1a1daeb3083e794e1db043229c04a906b28943 /usr.sbin/rpki-client
parent35788f98cc3c2050e17253ba4547e3d994a67bcf (diff)
Shuffle deck chairs so that the order is more logical (at least for me).
No functional change.
Diffstat (limited to 'usr.sbin/rpki-client')
-rw-r--r--usr.sbin/rpki-client/http.c164
1 files changed, 82 insertions, 82 deletions
diff --git a/usr.sbin/rpki-client/http.c b/usr.sbin/rpki-client/http.c
index 771265ec544..7b6aa68e383 100644
--- a/usr.sbin/rpki-client/http.c
+++ b/usr.sbin/rpki-client/http.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: http.c,v 1.22 2021/04/08 16:43:08 claudio Exp $ */
+/* $OpenBSD: http.c,v 1.23 2021/04/08 16:46:59 claudio Exp $ */
/*
* Copyright (c) 2020 Nils Fisher <nils_fisher@hotmail.com>
* Copyright (c) 2020 Claudio Jeker <claudio@openbsd.org>
@@ -312,24 +312,6 @@ http_free(struct http_connection *conn)
}
static int
-http_close(struct http_connection *conn)
-{
- if (conn->tls != NULL) {
- switch (tls_close(conn->tls)) {
- case TLS_WANT_POLLIN:
- return WANT_POLLIN;
- case TLS_WANT_POLLOUT:
- return WANT_POLLOUT;
- case 0:
- case -1:
- break;
- }
- }
-
- return -1;
-}
-
-static int
http_parse_uri(char *uri, char **ohost, char **oport, char **opath)
{
char *host, *port = NULL, *path;
@@ -426,46 +408,6 @@ http_new(size_t id, char *uri, char *modified_since, int outfd)
}
static int
-http_redirect(struct http_connection *conn, char *uri)
-{
- char *host, *port, *path;
-
- logx("redirect to %s", http_info(uri));
-
- if (http_parse_uri(uri, &host, &port, &path) == -1) {
- free(uri);
- return -1;
- }
-
- free(conn->url);
- conn->url = uri;
- free(conn->host);
- conn->host = host;
- free(conn->port);
- conn->port = port;
- conn->path = path;
- /* keep modified_since since that is part of the request */
- free(conn->last_modified);
- conn->last_modified = NULL;
- free(conn->buf);
- conn->buf = NULL;
- conn->bufpos = 0;
- conn->bufsz = 0;
- tls_close(conn->tls);
- tls_free(conn->tls);
- conn->tls = NULL;
- close(conn->fd);
- conn->state = STATE_INIT;
-
- /* TODO proxy support (overload of host and port) */
-
- if (http_resolv(conn, host, port) == -1)
- return -1;
-
- return 0;
-}
-
-static int
http_connect(struct http_connection *conn)
{
const char *cause = NULL;
@@ -669,29 +611,6 @@ http_request(struct http_connection *conn)
}
static int
-http_write(struct http_connection *conn)
-{
- ssize_t s;
-
- s = tls_write(conn->tls, conn->buf + conn->bufpos,
- conn->bufsz - conn->bufpos);
- if (s == -1) {
- warnx("%s: TLS write: %s", http_info(conn->url),
- tls_error(conn->tls));
- return -1;
- } else if (s == TLS_WANT_POLLIN) {
- return WANT_POLLIN;
- } else if (s == TLS_WANT_POLLOUT) {
- return WANT_POLLOUT;
- }
-
- conn->bufpos += s;
- if (conn->bufpos == conn->bufsz)
- return 0;
- return WANT_POLLOUT;
-}
-
-static int
http_parse_status(struct http_connection *conn, char *buf)
{
const char *errstr;
@@ -749,6 +668,46 @@ http_isredirect(struct http_connection *conn)
}
static int
+http_redirect(struct http_connection *conn, char *uri)
+{
+ char *host, *port, *path;
+
+ logx("redirect to %s", http_info(uri));
+
+ if (http_parse_uri(uri, &host, &port, &path) == -1) {
+ free(uri);
+ return -1;
+ }
+
+ free(conn->url);
+ conn->url = uri;
+ free(conn->host);
+ conn->host = host;
+ free(conn->port);
+ conn->port = port;
+ conn->path = path;
+ /* keep modified_since since that is part of the request */
+ free(conn->last_modified);
+ conn->last_modified = NULL;
+ free(conn->buf);
+ conn->buf = NULL;
+ conn->bufpos = 0;
+ conn->bufsz = 0;
+ tls_close(conn->tls);
+ tls_free(conn->tls);
+ conn->tls = NULL;
+ close(conn->fd);
+ conn->state = STATE_INIT;
+
+ /* TODO proxy support (overload of host and port) */
+
+ if (http_resolv(conn, host, port) == -1)
+ return -1;
+
+ return 0;
+}
+
+static int
http_parse_header(struct http_connection *conn, char *buf)
{
#define CONTENTLEN "Content-Length: "
@@ -965,6 +924,47 @@ http_read(struct http_connection *conn)
}
static int
+http_write(struct http_connection *conn)
+{
+ ssize_t s;
+
+ s = tls_write(conn->tls, conn->buf + conn->bufpos,
+ conn->bufsz - conn->bufpos);
+ if (s == -1) {
+ warnx("%s: TLS write: %s", http_info(conn->url),
+ tls_error(conn->tls));
+ return -1;
+ } else if (s == TLS_WANT_POLLIN) {
+ return WANT_POLLIN;
+ } else if (s == TLS_WANT_POLLOUT) {
+ return WANT_POLLOUT;
+ }
+
+ conn->bufpos += s;
+ if (conn->bufpos == conn->bufsz)
+ return 0;
+ return WANT_POLLOUT;
+}
+
+static int
+http_close(struct http_connection *conn)
+{
+ if (conn->tls != NULL) {
+ switch (tls_close(conn->tls)) {
+ case TLS_WANT_POLLIN:
+ return WANT_POLLIN;
+ case TLS_WANT_POLLOUT:
+ return WANT_POLLOUT;
+ case 0:
+ case -1:
+ break;
+ }
+ }
+
+ return -1;
+}
+
+static int
data_write(struct http_connection *conn)
{
ssize_t s;