~ubuntu-branches/debian/sid/varnish/sid

« back to all changes in this revision

Viewing changes to bin/varnishtest/vtc_http.c

  • Committer: Bazaar Package Importer
  • Author(s): Stig Sandbeck Mathisen
  • Date: 2011-03-21 10:16:07 UTC
  • mfrom: (24.1.2 experimental)
  • Revision ID: james.westby@ubuntu.com-20110321101607-528fzl583fqanas5
Tags: 2.1.5-2
ReleaseĀ forĀ unstable

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
#include "config.h"
30
30
 
31
31
#include "svnid.h"
32
 
SVNID("$Id: vtc_http.c 4761 2010-05-05 07:40:13Z tfheen $")
 
32
SVNID("$Id$")
33
33
 
34
34
#include <poll.h>
35
35
#include <stdio.h>
115
115
                                k = '!';
116
116
                        l = k;
117
117
                } else {
118
 
                        b[j] = l++;
119
 
                        if (l == '~')
 
118
                  b[j] = (char)l;
 
119
                        if (++l == '~')
120
120
                                l = '!';
121
121
                }
122
122
        }
505
505
        const char *proto = "HTTP/1.1";
506
506
        const char *status = "200";
507
507
        const char *msg = "Ok";
508
 
        int bodylen;
 
508
        int bodylen = 0;
509
509
        char *b, *c;
510
 
        char *body = NULL;
 
510
        char *body = NULL, *nullbody;
 
511
        int nolen = 0;
 
512
 
511
513
 
512
514
        (void)cmd;
513
515
        (void)vl;
518
520
 
519
521
        vsb_clear(hp->vsb);
520
522
 
 
523
        /* send a "Content-Length: 0" header unless something else happens */
 
524
        REPLACE(body, "");
 
525
        nullbody = body;
 
526
 
521
527
        for(; *av != NULL; av++) {
522
528
                if (!strcmp(*av, "-proto")) {
523
529
                        proto = av[1];
536
542
        vsb_printf(hp->vsb, "%s %s %s%s", proto, status, msg, nl);
537
543
 
538
544
        for(; *av != NULL; av++) {
539
 
                if (!strcmp(*av, "-hdr")) {
 
545
                if (!strcmp(*av, "-nolen")) {
 
546
                        nolen = 1;
 
547
                } else if (!strcmp(*av, "-hdr")) {
540
548
                        vsb_printf(hp->vsb, "%s%s", av[1], nl);
541
549
                        av++;
542
550
                } else
544
552
        }
545
553
        for(; *av != NULL; av++) {
546
554
                if (!strcmp(*av, "-body")) {
547
 
                        AZ(body);
 
555
                        assert(body == nullbody);
548
556
                        REPLACE(body, av[1]);
 
557
 
549
558
                        AN(body);
550
559
                        av++;
551
560
                        bodylen = strlen(body);
560
569
                                }
561
570
                        }
562
571
                } else if (!strcmp(*av, "-bodylen")) {
563
 
                        AZ(body);
 
572
                        assert(body == nullbody);
564
573
                        body = synth_body(av[1]);
565
574
                        bodylen = strlen(body);
566
575
                        av++;
569
578
        }
570
579
        if (*av != NULL)
571
580
                vtc_log(hp->vl, 0, "Unknown http txresp spec: %s\n", *av);
572
 
        if (body != NULL)
 
581
        if (body != NULL && !nolen)
573
582
                vsb_printf(hp->vsb, "Content-Length: %d%s", bodylen, nl);
574
583
        vsb_cat(hp->vsb, nl);
575
584
        if (body != NULL)
774
783
                vsb_printf(hp->vsb, "%x%s", v, nl);
775
784
                vsb_printf(hp->vsb, "%*.*s%s", v, v, buf, nl);
776
785
        }
777
 
        vsb_printf(hp->vsb, "%x%s", 0, nl);
 
786
        vsb_printf(hp->vsb, "%x%s%s", 0, nl, nl);
778
787
        http_write(hp, 4, "chunked");
779
788
}
780
789