Skip to content

Commit

Permalink
Enable HTTP basic authentication.
Browse files Browse the repository at this point in the history
  • Loading branch information
kristaps committed Oct 29, 2018
1 parent 64bcbc9 commit 0098ac9
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions slant-http.c
Expand Up @@ -164,11 +164,18 @@ http_write_ready(struct out *out, struct node *n, time_t t)
free(n->xfer.wbuf);
n->xfer.wbuf = NULL;

c = asprintf(&n->xfer.wbuf,
"GET %s HTTP/1.0\r\n"
"Host: %s\r\n"
"\r\n",
n->path, n->host);
c = NULL != n->httpauth ?
asprintf(&n->xfer.wbuf,
"GET %s HTTP/1.0\r\n"
"Host: %s\r\n"
"Authorization: Basic %s\r\n"
"\r\n",
n->path, n->host, n->httpauth) :
asprintf(&n->xfer.wbuf,
"GET %s HTTP/1.0\r\n"
"Host: %s\r\n"
"\r\n",
n->path, n->host);

if (c < 0) {
xwarn(out, NULL);
Expand Down

0 comments on commit 0098ac9

Please sign in to comment.