diff options
-rw-r--r-- | ge.c | 9 | ||||
-rw-r--r-- | gmid.c | 9 | ||||
-rw-r--r-- | gmid.h | 2 | ||||
-rw-r--r-- | server.c | 3 |
4 files changed, 8 insertions, 15 deletions
@@ -40,7 +40,7 @@ static const struct option opts[] = { }; void -log_request(struct client *c, char *meta, size_t l) +log_request(struct client *c, int code, const char *meta) { char b[GEMINI_URL_LEN]; const char *t; @@ -70,11 +70,8 @@ log_request(struct client *c, char *meta, size_t l) strlcpy(b, t, sizeof(b)); } - if ((t = memchr(meta, '\r', l)) == NULL) - t = meta + l; - - fprintf(stderr, "%s:%s GET %s %.*s\n", c->rhost, c->rserv, b, - (int)(t-meta), meta); + fprintf(stderr, "%s:%s GET %s %d %s\n", c->rhost, c->rserv, b, + code, meta); } void @@ -81,7 +81,7 @@ usage(void) /* used by the server process, defined here so gg can provide its own impl. */ void -log_request(struct client *c, char *meta, size_t l) +log_request(struct client *c, int code, const char *meta) { struct conf *conf = c->conf; char b[GEMINI_URL_LEN]; @@ -114,11 +114,8 @@ log_request(struct client *c, char *meta, size_t l) strlcpy(b, t, sizeof(b)); } - if ((t = memchr(meta, '\r', l)) == NULL) - t = meta + l; - - ec = asprintf(&fmted, "%s:%s GET %s %.*s", c->rhost, c->rserv, b, - (int)(t-meta), meta); + ec = asprintf(&fmted, "%s:%s GET %s %d %s", c->rhost, c->rserv, b, + code, meta); if (ec == -1) fatal("asprintf"); @@ -365,7 +365,7 @@ char *data_dir(void); void load_local_cert(struct vhost*, const char*, const char*); /* gmid.c / ge.c */ -void log_request(struct client *, char *, size_t); +void log_request(struct client *, int, const char *); /* config.c */ struct conf *config_new(void); @@ -1167,8 +1167,7 @@ start_reply(struct client *c, int code, const char *meta) bufferevent_write(c->bev, "\r\n", 2); if (!vhost_disable_log(c->host, c->iri.path)) - log_request(c, (char *)EVBUFFER_DATA(evb), - EVBUFFER_LENGTH(evb)); + log_request(c, code, meta); if (code != 20) c->type = REQUEST_DONE; |