]> err.no Git - varnish/commitdiff
Use HttpdBuildSbuf()
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Thu, 6 Apr 2006 07:50:58 +0000 (07:50 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Thu, 6 Apr 2006 07:50:58 +0000 (07:50 +0000)
Enable Id keyword

git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@121 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishd/cache_pass.c
varnish-cache/bin/varnishd/cache_pipe.c

index 1e6fb11d68de5e38b6c8aa236970f3e36735a111..34e769fb3b240b963f71c3d7538050ec75f35250 100644 (file)
@@ -42,65 +42,32 @@ PassSession(struct worker *w, struct sess *sp)
        fd = VBE_GetFd(sp->backend, &fd_token);
        assert(fd != -1);
 
-       sbuf_clear(w->sb);
-       assert(w->sb != NULL);
-       sbuf_cat(w->sb, sp->http.req);
-       sbuf_cat(w->sb, " ");
-       sbuf_cat(w->sb, sp->http.url);
-       sbuf_cat(w->sb, " ");
-       sbuf_cat(w->sb, sp->http.proto);
-       sbuf_cat(w->sb, "\r\n");
-#define HTTPH(a, b, c, d, e, f, g)                             \
-       do {                                                    \
-               if (d && sp->http.b != NULL) {                  \
-                       sbuf_cat(w->sb, a ": ");                \
-                       sbuf_cat(w->sb, sp->http.b);            \
-                       sbuf_cat(w->sb, "\r\n");                \
-               }                                               \
-       } while (0);
-#include "http_headers.h"
-#undef HTTPH
-       sbuf_cat(w->sb, "\r\n");
-       sbuf_finish(w->sb);
+       HttpdBuildSbuf(0, 1, w->sb, sp);
+
        i = write(fd, sbuf_data(w->sb), sbuf_len(w->sb));
        assert(i == sbuf_len(w->sb));
 
+       /* XXX: copy any contents */
+
+
        memset(&sp2, 0, sizeof sp2);
        sp2.rd_e = &w->e1;
        sp2.fd = fd;
        HttpdGetHead(&sp2, w->eb, PassReturn);
        event_base_loop(w->eb, 0);
-       sbuf_clear(w->sb);
-       sbuf_cat(w->sb, sp2.http.proto);
-       sbuf_cat(w->sb, " ");
-       sbuf_cat(w->sb, sp2.http.status);
-       sbuf_cat(w->sb, " ");
-       sbuf_cat(w->sb, sp2.http.response);
-       sbuf_cat(w->sb, "\r\n");
-#define HTTPH(a, b, c, d, e, f, g)                             \
-       do {                                                    \
-               if (d && sp2.http.b != NULL) {                  \
-                       sbuf_cat(w->sb, a ": ");                \
-                       sbuf_cat(w->sb, sp2.http.b);            \
-                       sbuf_cat(w->sb, "\r\n");                \
-               }                                               \
-       } while (0);
-#include "http_headers.h"
-#undef HTTPH
-       sbuf_cat(w->sb, "\r\n");
-       sbuf_finish(w->sb);
+
+       HttpdBuildSbuf(1, 1, w->sb, &sp2);
        i = write(sp->fd, sbuf_data(w->sb), sbuf_len(w->sb));
        assert(i == sbuf_len(w->sb));
+
        if (sp2.http.H_Content_Length != NULL) {
                cl = strtoumax(sp2.http.H_Content_Length, NULL, 0);
-               VSL(SLT_Debug, 0, "CL %ju %u %u", cl, sp->rcv_len, sp->hdr_end);
                i = fcntl(sp2.fd, F_GETFL);
                i &= ~O_NONBLOCK;
                i = fcntl(sp2.fd, F_SETFL, i);
                assert(i != -1);
                i = sp2.rcv_len - sp2.hdr_end;
                if (i > 0) {
-                       VSL(SLT_Debug, 0, "Wr1 %d", i);
                        j = write(sp->fd, sp2.rcv + sp2.hdr_end, i);
                        assert(j == i);
                        cl -= i;
@@ -112,14 +79,15 @@ PassSession(struct worker *w, struct sess *sp)
                        i = recv(sp2.fd, buf, j, 0);
                        assert(i >= 0);
                        if (i > 0) {
-                               VSL(SLT_Debug, 0, "Rd %d", i);
                                cl -= i;
                                j = write(sp->fd, buf, i);
                                assert(j == i);
                        } else if (i == 0) {
-                               VSL(SLT_Debug, 0, "EOF %d", i);
                                break;
                        }
                }
        }
+
+       /* XXX: move remaining input in sp->rcv */
+       /* XXX: return session to acceptor */
 }
index a8257d0580355d3dda4174e3ca11ea6f48bc1046..6ce7b1d9d11e559e47dd058f90828df1f14a6776 100644 (file)
@@ -44,37 +44,21 @@ rdf(int fd, short event, void *arg)
 void
 PipeSession(struct worker *w, struct sess *sp)
 {
-       int fd, i;
+       int fd, i, j;
        void *fd_token;
        struct edir e1, e2;
 
        fd = VBE_GetFd(sp->backend, &fd_token);
        assert(fd != -1);
 
-       sbuf_clear(w->sb);
-       assert(w->sb != NULL);
-       sbuf_cat(w->sb, sp->http.req);
-       sbuf_cat(w->sb, " ");
-       sbuf_cat(w->sb, sp->http.url);
-       if (sp->http.proto != NULL) {
-               sbuf_cat(w->sb, " ");
-               sbuf_cat(w->sb, sp->http.proto);
-       }
-       sbuf_cat(w->sb, "\r\n");
-#define HTTPH(a, b, c, d, e, f, g)                             \
-       do {                                                    \
-               if (sp->http.b != NULL) {                       \
-                       sbuf_cat(w->sb, a ": ");                \
-                       sbuf_cat(w->sb, sp->http.b);            \
-                       sbuf_cat(w->sb, "\r\n");                \
-               }                                               \
-       } while (0);
-#include "http_headers.h"
-#undef HTTPH
-       sbuf_cat(w->sb, "\r\n");
-       sbuf_finish(w->sb);
+       HttpdBuildSbuf(0, 0, w->sb, sp);
        i = write(fd, sbuf_data(w->sb), sbuf_len(w->sb));
        assert(i == sbuf_len(w->sb));
+       i = sp->rcv_len - sp->hdr_end;
+       if (i > 0) {
+               j = write(sp->fd, sp->rcv + sp->hdr_end, i);
+               assert(j == i);
+       }
 
        e1.fd = fd;
        e2.fd = sp->fd;