Commit 35526adc authored by Jim Jagielski's avatar Jim Jagielski
Browse files

And standard format - no functional change


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1810363 13f79535-47bb-0310-9956-ffa450edef68
parent 112f9d0f
Loading
Loading
Loading
Loading
+212 −195
Original line number Diff line number Diff line
@@ -90,15 +90,16 @@ static int uwsgi_canon(request_rec *r, char *url)
        return HTTP_BAD_REQUEST;
    }

    r->filename = apr_pstrcat(r->pool, "proxy:" UWSGI_SCHEME "://", host, sport, "/",
    r->filename =
        apr_pstrcat(r->pool, "proxy:" UWSGI_SCHEME "://", host, sport, "/",
                    path, NULL);

    return OK;
}


static int uwsgi_send(proxy_conn_rec *conn, const char *buf, apr_size_t length,
                   request_rec *r)
static int uwsgi_send(proxy_conn_rec * conn, const char *buf,
                      apr_size_t length, request_rec *r)
{
    apr_status_t rv;
    apr_size_t written;
@@ -157,7 +158,10 @@ static int uwsgi_send_headers(request_rec *r, proxy_conn_rec *conn)

    if (script_name && path_info) {
        if (strcmp(path_info, "/")) {
            apr_table_set(r->subprocess_env, "SCRIPT_NAME", apr_pstrndup(r->pool, script_name, strlen(script_name)-strlen(path_info)));
            apr_table_set(r->subprocess_env, "SCRIPT_NAME",
                          apr_pstrndup(r->pool, script_name,
                                       strlen(script_name) -
                                       strlen(path_info)));
        }
        else {
            if (!strcmp(script_name, "/")) {
@@ -181,12 +185,14 @@ static int uwsgi_send_headers(request_rec *r, proxy_conn_rec *conn)
        keylen = strlen(env[j].key);
        *ptr++ = (uint8_t) (keylen & 0xff);
        *ptr++ = (uint8_t) ((keylen >> 8) & 0xff);
	memcpy(ptr, env[j].key, keylen) ; ptr+=keylen;
        memcpy(ptr, env[j].key, keylen);
        ptr += keylen;

        vallen = strlen(env[j].val);
        *ptr++ = (uint8_t) (vallen & 0xff);
        *ptr++ = (uint8_t) ((vallen >> 8) & 0xff);
	memcpy(ptr, env[j].val, vallen) ; ptr+=vallen;
        memcpy(ptr, env[j].val, vallen);
        ptr += vallen;
    }

    pktsize = headerlen - 4;
@@ -261,7 +267,8 @@ static request_rec *make_fake_req(conn_rec *c, request_rec *r)
    return rp;
}

static int uwsgi_response(request_rec *r, proxy_conn_rec *backend, proxy_server_conf *conf)
static int uwsgi_response(request_rec *r, proxy_conn_rec * backend,
                          proxy_server_conf * conf)
{

    char buffer[HUGE_STRING_LEN];
@@ -303,9 +310,11 @@ static int uwsgi_response(request_rec *r, proxy_conn_rec *backend, proxy_server_
    /* Position of http status code */
    if (apr_date_checkmask(buffer, "HTTP/#.# ###*")) {
        status_start = 9;
	} else if (apr_date_checkmask(buffer, "HTTP/# ###*")) {
    }
    else if (apr_date_checkmask(buffer, "HTTP/# ###*")) {
        status_start = 7;
	} else {
    }
    else {
        // oops
        return HTTP_INTERNAL_SERVER_ERROR;
    }
@@ -317,7 +326,8 @@ static int uwsgi_response(request_rec *r, proxy_conn_rec *backend, proxy_server_

    if (keepchar != '\0') {
        buffer[status_end] = keepchar;
	} else {
    }
    else {
        /* 2616 requires the space in Status-Line; the origin
         * server may have sent one but ap_rgetline_core will
         * have stripped it. */
@@ -330,11 +340,15 @@ static int uwsgi_response(request_rec *r, proxy_conn_rec *backend, proxy_server_
    while ((len = ap_getline(buffer, sizeof(buffer), rp, 1)) > 0) {
        value = strchr(buffer, ':');
        // invalid header skip
		if (!value) continue;
        if (!value)
            continue;
        *value = '\0';
        ++value;
		while (apr_isspace(*value)) ++value; 
		for (end = &value[strlen(value)-1]; end > value && apr_isspace(*end); --end) *end = '\0';
        while (apr_isspace(*value))
            ++value;
        for (end = &value[strlen(value) - 1];
             end > value && apr_isspace(*end); --end)
            *end = '\0';
        apr_table_add(r->headers_out, buffer, value);
    }

@@ -344,7 +358,8 @@ static int uwsgi_response(request_rec *r, proxy_conn_rec *backend, proxy_server_

    // honor ProxyErrorOverride and ErrorDocument
#if AP_MODULE_MAGIC_AT_LEAST(20101106,0)
    proxy_dir_conf *dconf = ap_get_module_config(r->per_dir_config, &proxy_module);
    proxy_dir_conf *dconf =
        ap_get_module_config(r->per_dir_config, &proxy_module);
    if (dconf->error_override && ap_is_HTTP_ERROR(r->status)) {
#else
    if (conf->error_override && ap_is_HTTP_ERROR(r->status)) {
@@ -361,8 +376,7 @@ static int uwsgi_response(request_rec *r, proxy_conn_rec *backend, proxy_server_

    while (!finish) {
        rv = ap_get_brigade(rp->input_filters, bb,
                                        AP_MODE_READBYTES, mode,
                                        conf->io_buffer_size);
                            AP_MODE_READBYTES, mode, conf->io_buffer_size);
        if (APR_STATUS_IS_EAGAIN(rv)
            || (rv == APR_SUCCESS && APR_BRIGADE_EMPTY(bb))) {
            e = apr_bucket_flush_create(c->bucket_alloc);
@@ -396,12 +410,15 @@ static int uwsgi_response(request_rec *r, proxy_conn_rec *backend, proxy_server_
        ap_proxy_buckets_lifetime_transform(r, bb, pass_bb);

        // found the last brigade?
		if (APR_BUCKET_IS_EOS(APR_BRIGADE_LAST(bb))) finish = 1;
        if (APR_BUCKET_IS_EOS(APR_BRIGADE_LAST(bb)))
            finish = 1;

        // do not pass chunk if it is zero_sized
        apr_brigade_length(pass_bb, 0, &readbytes);

		if ((readbytes > 0 && ap_pass_brigade(r->output_filters, pass_bb) != APR_SUCCESS) || c->aborted) {
        if ((readbytes > 0
             && ap_pass_brigade(r->output_filters, pass_bb) != APR_SUCCESS)
            || c->aborted) {
            finish = 1;
        }

@@ -436,8 +453,7 @@ static int uwsgi_handler(request_rec *r, proxy_worker *worker,
    apr_uri_t *uri = apr_palloc(r->pool, sizeof(*uri));

    if (strncasecmp(url, UWSGI_SCHEME "://", sizeof(UWSGI_SCHEME) + 2)) {
        ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
                      "declining URL %s", url);
        ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "declining URL %s", url);
        return DECLINED;
    }

@@ -454,8 +470,7 @@ static int uwsgi_handler(request_rec *r, proxy_worker *worker,
    int decode_status = ap_unescape_url(url + w_len - delta);
    if (decode_status) {
        ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
                      "unable to decode uri: %s",
                      url+w_len-delta);
                      "unable to decode uri: %s", url + w_len - delta);
        return HTTP_INTERNAL_SERVER_ERROR;
    }
    apr_table_add(r->subprocess_env, "PATH_INFO", url + w_len - delta);
@@ -472,7 +487,8 @@ static int uwsgi_handler(request_rec *r, proxy_worker *worker,
    /* Step One: Determine Who To Connect To */
    status = ap_proxy_determine_connection(p, r, conf, worker, backend,
                                           uri, &url, proxyname, proxyport,
                                           server_portstr, sizeof(server_portstr));
                                           server_portstr,
                                           sizeof(server_portstr));
    if (status != OK) {
        goto cleanup;
    }
@@ -490,7 +506,8 @@ static int uwsgi_handler(request_rec *r, proxy_worker *worker,
    /* Step Three: Create conn_rec */
    if (!backend->connection) {
        if ((status = ap_proxy_connection_create(UWSGI_SCHEME, backend,
						r->connection, r->server)) != OK)
                                                 r->connection,
                                                 r->server)) != OK)
            goto cleanup;
    }