X-Git-Url: http://dolda2000.com/gitweb/?a=blobdiff_plain;f=src%2Fhtparser.c;h=3fcca75bea6a0175b55b56e3a9f63b0f4e7e6dcd;hb=e5ad70cbd3acc40df2546bd466c87f55417cbbe6;hp=953ddac89f5faaa64ccb2691b50682c98b1f16de;hpb=f0cbd8d7d17f9da506af58f1ce5364ade86d574e;p=ashd.git diff --git a/src/htparser.c b/src/htparser.c index 953ddac..3fcca75 100644 --- a/src/htparser.c +++ b/src/htparser.c @@ -38,6 +38,23 @@ static int plex; +static void trimx(struct hthead *req) +{ + int i; + + i = 0; + while(i < req->noheaders) { + if(!strncasecmp(req->headers[i][0], "x-ash-", 6)) { + free(req->headers[i][0]); + free(req->headers[i][1]); + free(req->headers[i]); + memmove(req->headers + i, req->headers + i + 1, sizeof(*req->headers) * (--req->noheaders - i)); + } else { + i++; + } + } +} + static struct hthead *parsereq(FILE *in) { struct hthead *req; @@ -85,6 +102,7 @@ static struct hthead *parsereq(FILE *in) req = mkreq(method.b, url.b, ver.b); if(parseheaders(req, in)) goto fail; + trimx(req); goto out; fail: @@ -415,10 +433,6 @@ int main(int argc, char **argv) exit(1); } } - if((argc - optind) < 3) { - usage(stderr); - exit(1); - } s1 = 0; for(i = optind; i < argc; i++) { if(!strcmp(argv[i], "--"))