On 05/03/2011 06:35 AM, ChangCheng wrote: > > I don't know what's reason caused this error. This is core part of my plug-in > down below:
Nothing rings any bells, but let me give some input on the plugin code. > const char *RGWIDName = "xxid"; > static void handle_read_request(TSHttpTxn txnp, TSCont contp) { > TSMBuffer bufp; > TSMLoc hdr_loc; > int tmp_len; > int tmp_len1; > char *modified; > char *modifiedURL; > char *query; > const char *methodGet; > if (TSHttpTxnClientReqGet(txnp, &bufp, &hdr_loc) != TS_SUCCESS) { > TSError("couldn't retrieve client request header\n"); > goto done; > } > /**strip out only work on get and head method*/ > methodGet = TSHttpHdrMethodGet(bufp, hdr_loc, &tmp_len1); > if (methodGet == TS_HTTP_METHOD_GET || methodGet == TS_HTTP_METHOD_HEAD) { > modifiedURL = TSHttpTxnEffectiveUrlStringGet(txnp, &tmp_len); This modifiedURL must be TSfree()'d before the plugin is done. > modified = strstr(modifiedURL, RGWIDName); > if (modified != NULL) { Assuming the GWIDName can only occur in the query parameters, why are you not just getting the query parms, using TSUrlHttpQueryGet() ? That has the advantage too that you don't need to worry about freeing, and it will also be *much* faster, since it works directly on the marshal buffers. > TSUrlCreate(urlBuf, &urlLoc); > if (TSUrlParse(urlBuf, urlLoc, (const char **) &start, end) > != TS_PARSE_DONE) { > TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc); > TSUrlDestroy(urlBuf, urlLoc); > TSHandleMLocRelease(urlBuf, NULL, urlLoc); > TSError("[all-plugin<handle_read_request>] Can't not parse > URL"); > goto done; > } > > if (TSHttpHdrUrlSet(bufp, hdr_loc, urlLoc) == TS_ERROR) { Same here, why not just use TSUrlHttpQuerySet() ? That avoids all this URL creation, parsing, and URL copying. If the stuff is not in the query arguments, but in e.g. the URI path, there are similar APIs to Get() and Set() that component. In almost all cases, it's easier and much faster to work on the various components, instead of creating that URL string copy, and then work on that. -- Leif