~ubuntu-branches/ubuntu/utopic/haproxy/utopic-proposed

« back to all changes in this revision

Viewing changes to src/proto_http.c

  • Committer: Bazaar Package Importer
  • Author(s): Arnaud Cornet
  • Date: 2009-02-17 08:55:12 UTC
  • mfrom: (1.1.5 upstream) (2.1.3 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090217085512-qmij51nun3rbxorz
Fix build without debian/patches directory (Closes: #515682) using
/usr/share/quilt/quilt.make.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1925
1925
                                        int ret;
1926
1926
 
1927
1927
                                        ret = acl_exec_cond(rule->cond, cur_proxy, t, txn, ACL_DIR_REQ);
1928
 
                                        if (cond->pol == ACL_COND_UNLESS)
 
1928
                                        if (rule->cond->pol == ACL_COND_UNLESS)
1929
1929
                                                ret = !ret;
1930
1930
 
1931
1931
                                        if (ret) {
2009
2009
                 * the fields will stay coherent and the URI will not move.
2010
2010
                 * This should only be performed in the backend.
2011
2011
                 */
2012
 
                if ((t->be->cookie_name || t->be->appsession_name || t->be->capture_name)
 
2012
                if ((t->be->cookie_name || t->be->appsession_name || t->fe->capture_name)
2013
2013
                    && !(txn->flags & (TX_CLDENY|TX_CLTARPIT)))
2014
2014
                        manage_client_side_cookies(t, req);
2015
2015
 
2077
2077
                 */
2078
2078
                if (!(t->flags & (SN_ASSIGNED|SN_DIRECT)) &&
2079
2079
                     t->txn.meth == HTTP_METH_POST && t->be->url_param_name != NULL &&
2080
 
                     t->be->url_param_post_limit != 0 && req->total < BUFSIZE &&
 
2080
                     t->be->url_param_post_limit != 0 && req->l < BUFSIZE &&
2081
2081
                     memchr(msg->sol + msg->sl.rq.u, '?', msg->sl.rq.u_l) == NULL) {
2082
2082
                        /* are there enough bytes here? total == l || r || rlim ?
2083
2083
                         * len is unsigned, but eoh is int,
2085
2085
                         * eoh is the first empty line of the header
2086
2086
                         */
2087
2087
                        /* already established CRLF or LF at eoh, move to start of message, find message length in buffer */
2088
 
                        unsigned long len = req->total - (msg->sol[msg->eoh] == '\r' ? msg->eoh + 2 : msg->eoh + 1);
 
2088
                        unsigned long len = req->l - (msg->sol[msg->eoh] == '\r' ? msg->eoh + 2 : msg->eoh + 1);
2089
2089
 
2090
2090
                        /* If we have HTTP/1.1 and Expect: 100-continue, then abort.
2091
2091
                         * We can't assume responsibility for the server's decision,
2686
2686
                        }
2687
2687
                        else {
2688
2688
                                fd_delete(t->srv_fd);
2689
 
                                if (t->srv) {
 
2689
                                if (t->srv)
2690
2690
                                        t->srv->cur_sess--;
2691
 
                                        sess_change_server(t, NULL);
2692
 
                                }
2693
2691
 
2694
2692
                                if (!(req->flags & BF_WRITE_STATUS))
2695
2693
                                        conn_err = SN_ERR_SRVTO; // it was a connect timeout.
3195
3193
                /*
3196
3194
                 * 4: check for server cookie.
3197
3195
                 */
3198
 
                if (t->be->cookie_name || t->be->appsession_name || t->be->capture_name
 
3196
                if (t->be->cookie_name || t->be->appsession_name || t->fe->capture_name
3199
3197
                    || (t->be->options & PR_O_CHK_CACHE))
3200
3198
                        manage_server_side_cookies(t, rep);
3201
3199
 
3615
3613
                         */
3616
3614
                        struct http_msg * msg = &t->txn.req;
3617
3615
                        unsigned long body = msg->sol[msg->eoh] == '\r' ? msg->eoh + 2 :msg->eoh + 1;
3618
 
                        unsigned long len  = req->total - body;
 
3616
                        unsigned long len  = req->l - body;
3619
3617
                        long long limit = t->be->url_param_post_limit;
3620
3618
                        struct hdr_ctx ctx;
3621
3619
                        ctx.idx = 0;
3623
3621
                        http_find_header2("Transfer-Encoding", 17, msg->sol, &txn->hdr_idx, &ctx);
3624
3622
                        if ( ctx.idx && strncasecmp(ctx.line+ctx.val,"chunked",ctx.vlen)==0) {
3625
3623
                                unsigned int chunk = 0;
3626
 
                                while ( body < req->total && !HTTP_IS_CRLF(msg->sol[body])) {
 
3624
                                while ( body < req->l && !HTTP_IS_CRLF(msg->sol[body])) {
3627
3625
                                        char c = msg->sol[body];
3628
3626
                                        if (ishex(c)) {
3629
3627
                                                unsigned int hex = toupper(c) - '0';
3635
3633
                                        body++;
3636
3634
                                        len--;
3637
3635
                                }
3638
 
                                if ( body == req->total )
 
3636
                                if ( body + 2 >= req->l )
3639
3637
                                        return 0; /* end of buffer? data missing! */
3640
3638
 
3641
3639
                                if ( memcmp(msg->sol+body, "\r\n", 2) != 0 )
4602
4600
                txn->flags |= TX_SCK_ANY;
4603
4601
 
4604
4602
 
4605
 
                /* maybe we only wanted to see if there was a set-cookie */
 
4603
                /* maybe we only wanted to see if there was a set-cookie. Note that
 
4604
                 * the cookie capture is declared on the frontend.
 
4605
                 */
4606
4606
                if (t->be->cookie_name == NULL &&
4607
4607
                    t->be->appsession_name == NULL &&
4608
 
                    t->be->capture_name == NULL)
 
4608
                    t->fe->capture_name == NULL)
4609
4609
                        return;
4610
4610
 
4611
4611
                p1 = cur_ptr + val; /* first non-space char after 'Set-Cookie:' */
4637
4637
                         */
4638
4638
 
4639
4639
                        /* first, let's see if we want to capture it */
4640
 
                        if (t->be->capture_name != NULL &&
 
4640
                        if (t->fe->capture_name != NULL &&
4641
4641
                            txn->srv_cookie == NULL &&
4642
 
                            (p4 - p1 >= t->be->capture_namelen) &&
4643
 
                            memcmp(p1, t->be->capture_name, t->be->capture_namelen) == 0) {
 
4642
                            (p4 - p1 >= t->fe->capture_namelen) &&
 
4643
                            memcmp(p1, t->fe->capture_name, t->fe->capture_namelen) == 0) {
4644
4644
                                int log_len = p4 - p1;
4645
4645
 
4646
4646
                                if ((txn->srv_cookie = pool_alloc2(pool2_capture)) == NULL) {
4647
4647
                                        Alert("HTTP logging : out of memory.\n");
4648
4648
                                }
4649
4649
 
4650
 
                                if (log_len > t->be->capture_len)
4651
 
                                        log_len = t->be->capture_len;
 
4650
                                if (log_len > t->fe->capture_len)
 
4651
                                        log_len = t->fe->capture_len;
4652
4652
                                memcpy(txn->srv_cookie, p1, log_len);
4653
4653
                                txn->srv_cookie[log_len] = 0;
4654
4654
                        }
5062
5062
        /* The request is valid, the user is authenticated. Let's start sending
5063
5063
         * data.
5064
5064
         */
 
5065
        EV_FD_CLR(t->cli_fd, DIR_RD);
 
5066
        buffer_shutr(t->req);
 
5067
        buffer_shutr(t->rep);
5065
5068
        t->cli_state = CL_STSHUTR;
5066
5069
        t->req->rlim = t->req->data + BUFSIZE; /* no more rewrite needed */
5067
5070
        t->logs.tv_request = now;