2 * Dolda Connect - Modular multiuser Direct Connect-style client
3 * Copyright (C) 2007 Fredrik Tolf <fredrik@dolda2000.com>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
34 if((u = parseurl(url)) == NULL) {
35 fprintf(stderr, "httest: %s: invalid url\n", url);
38 printf("host: %s\n", u->host);
39 printf("port: %i\n", u->port);
40 printf("path: %s\n", u->path);
41 printf("query: %s\n", u->query);
42 printf("fragment: %s\n", u->fragment);
54 if((u = parseurl(url)) == NULL) {
55 fprintf(stderr, "httest: %s: invalid url\n", url);
62 pfd.events = htpollflags(c);
63 if(poll(&pfd, 1, -1) < 0) {
64 fprintf(stderr, "httest: %s: %s\n", url, strerror(errno));
68 if((ret = htprocess(c, pfd.revents)) < 0) {
69 fprintf(stderr, "httest: %s: %s\n", url, strerror(errno));
77 printf("%i %s\n", c->rescode, c->resstr);
78 for(p = c->headers; p != NULL; p = p->next)
79 printf("%s: %s\n", p->key, p->val);
91 if((u = parseurl(url)) == NULL) {
92 fprintf(stderr, "httest: %s: invalid url\n", url);
100 pfd.events = htpollflags(c);
101 if(poll(&pfd, 1, -1) < 0) {
102 fprintf(stderr, "httest: %s: %s\n", url, strerror(errno));
106 if((ret = htprocess(c, pfd.revents)) < 0) {
107 fprintf(stderr, "httest: %s: %s\n", url, strerror(errno));
111 while(c->databufdata > 0) {
112 ret2 = write(1, c->databuf, c->databufdata);
113 memmove(c->databuf, c->databuf + ret2, c->databufdata -= ret2);
118 printf("%i %s\n", c->rescode, c->resstr);
119 for(p = c->headers; p != NULL; p = p->next)
120 printf("%s: %s\n", p->key, p->val);
124 int main(int argc, char **argv) {
127 for(i = 1; i < argc; i++) {
128 if(!strcmp(argv[i], "parse")) {
130 } else if(!strcmp(argv[i], "head")) {
132 } else if(!strcmp(argv[i], "get")) {