[ https://issues.apache.org/jira/browse/TS-2953?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14072956#comment-14072956 ]
portl4t commented on TS-2953: ----------------------------- TSHttpTxnEffectiveUrlStringGet(...) is a function which can be used to get the whole url, you can see this function in proxy/InkAPI.cc, and there may be other plugins which had used this function. > 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 > Components: Core, CPP API, Logging > Affects Versions: 4.2.1 > Reporter: Vasile Bogdan Raica > Labels: API > > 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)