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);
99 pfd.events = htpollflags(c);
100 if(poll(&pfd, 1, -1) < 0) {
101 fprintf(stderr, "httest: %s: %s\n", url, strerror(errno));
105 if((ret = htprocess(c, pfd.revents)) < 0) {
106 fprintf(stderr, "httest: %s: %s\n", url, strerror(errno));
110 while(c->databufdata > 0) {
111 ret2 = write(1, c->databuf, c->databufdata);
112 memmove(c->databuf, c->databuf + ret2, c->databufdata -= ret2);
117 printf("%i %s\n", c->rescode, c->resstr);
118 for(p = c->headers; p != NULL; p = p->next)
119 printf("%s: %s\n", p->key, p->val);
123 int main(int argc, char **argv) {
126 for(i = 1; i < argc; i++) {
127 if(!strcmp(argv[i], "parse")) {
129 } else if(!strcmp(argv[i], "head")) {
131 } else if(!strcmp(argv[i], "get")) {