You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficserver.apache.org by "Vasile Bogdan Raica (JIRA)" <ji...@apache.org> on 2014/07/23 03:36:39 UTC

[jira] [Created] (TS-2953) GET Host header in reverse proxy setup

Vasile Bogdan Raica created TS-2953:
---------------------------------------

             Summary: GET Host header in reverse proxy setup
                 Key: TS-2953
                 URL: https://issues.apache.org/jira/browse/TS-2953
             Project: Traffic Server
          Issue Type: Bug
            Reporter: Vasile Bogdan Raica


Hello, been trying this for 3 days, I think this is a bug. See bellow code, this has been tested on TS_HTTP_PRE_REMAP_HOOK and TS_HTTP_READ_REQUEST_HDR_HOOK. Also the example for blacklist, which uses the same thing, also fails.

Same goes with getting the URL string, it will remove the hostname and leave the requested part, eg.

http:///somefile.php

(there are 3 slashes there).

I've been using ATS for about 3 days (yes short time) and trying to make a plugin for it and I can't seem to get what I want ... I may be missing something, and if so, I apologize for taking your time to read this and if possible, kindly show me the right way to do this if possible.

static void
handle_request(TSHttpTxn txnp, TSCont contp) {
    TSMBuffer bufp; // TSMBuffer
    TSMLoc hdr_loc; // TSMLoc offset
    TSMLoc url_loc; // TSMLoc locp
    const char *host;
    int host_length;

    // getting client request
    errorCode = TSHttpTxnClientReqGet (txnp, &bufp, &hdr_loc);
    if (errorCode != TS_SUCCESS) {
        TSError ("couldn't retrieve client request header\n");
        goto done;
    } else {
        TSTextLogObjectWrite(logFile, "Reading client request...");
    }

    // getting client requested url
    errorCode = TSHttpHdrUrlGet (bufp, hdr_loc, &url_loc);
    if (errorCode != TS_SUCCESS) {
        TSError ("couldn't retrieve request url\n");
        TSHandleMLocRelease (bufp, TS_NULL_MLOC, hdr_loc);
        goto done;
    } else {
        TSTextLogObjectWrite(logFile, "Reading url_loc request...");
    }

    // getting  host
    host = TSUrlHostGet (bufp, url_loc, &host_length);
    TSTextLogObjectWrite(logFile, "Getting host header... %s", host);
    if (!host) {
        TSError ("couldn't retrieve request host header \n");
        TSHandleMLocRelease (bufp, hdr_loc, url_loc);
        TSHandleMLocRelease (bufp, TS_NULL_MLOC, hdr_loc);
        goto done;
    } else {
        TSTextLogObjectWrite(logFile, "Getting host header... %s", host);
    }

    done:
        TSTextLogObjectWrite(logFile, "Allowing http event to continue ...");
        TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE);
}



--
This message was sent by Atlassian JIRA
(v6.2#6252)