Dolda2000 GitWeb
/
ashd.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
c4149d4
)
htparser: Affix a unique connection ID to each request.
author
Fredrik Tolf
<fredrik@dolda2000.com>
Mon, 11 Aug 2014 02:17:41 +0000
(
04:17
+0200)
committer
Fredrik Tolf
<fredrik@dolda2000.com>
Mon, 11 Aug 2014 02:17:41 +0000
(
04:17
+0200)
src/htparser.c
patch
|
blob
|
blame
|
history
diff --git
a/src/htparser.c
b/src/htparser.c
index
1dbb8ee
..
a20b329
100644
(file)
--- a/
src/htparser.c
+++ b/
src/htparser.c
@@
-280,15
+280,35
@@
static int http10keep(struct hthead *req, struct hthead *resp)
}
}
}
}
+static char *connid(void)
+{
+ static struct charbuf cur;
+ int i;
+ char *ret;
+
+ for(i = 0; i < cur.d; i++) {
+ if((++cur.b[i]) > 'Z')
+ cur.b[i] = 'A';
+ else
+ goto done;
+ }
+ bufadd(cur, 'A');
+done:
+ ret = memcpy(smalloc(cur.d + 1), cur.b, cur.d);
+ ret[cur.d] = 0;
+ return(ret);
+}
+
void serve(FILE *in, struct conn *conn)
{
int pfds[2];
FILE *out;
struct hthead *req, *resp;
void serve(FILE *in, struct conn *conn)
{
int pfds[2];
FILE *out;
struct hthead *req, *resp;
- char *hd;
+ char *hd
, *id
;
off_t dlen;
int keep;
off_t dlen;
int keep;
+ id = connid();
out = NULL;
req = resp = NULL;
while(plex >= 0) {
out = NULL;
req = resp = NULL;
while(plex >= 0) {
@@
-297,6
+317,7
@@
void serve(FILE *in, struct conn *conn)
if(!canonreq(req))
break;
if(!canonreq(req))
break;
+ headappheader(req, "X-Ash-Connection-ID", id);
if((conn->initreq != NULL) && conn->initreq(conn, req))
break;
if((conn->initreq != NULL) && conn->initreq(conn, req))
break;
@@
-399,6
+420,7
@@
void serve(FILE *in, struct conn *conn)
if(resp != NULL)
freehthead(resp);
fclose(in);
if(resp != NULL)
freehthead(resp);
fclose(in);
+ free(id);
}
static void plexwatch(struct muth *muth, va_list args)
}
static void plexwatch(struct muth *muth, va_list args)