The returned string must be freed with TSfree() unless it is equal to the constant NotFound.
| 367 | // The returned string must be freed with TSfree() unless it is equal to the constant NotFound. |
| 368 | // |
| 369 | static const char * |
| 370 | getRemapUrlStr(TSHttpTxn txnp, TSReturnCode (*remapUrlGetFunc)(TSHttpTxn, TSMLoc *), int &urlStrLen) |
| 371 | { |
| 372 | TSMLoc urlLoc; |
| 373 | |
| 374 | TSReturnCode rc = remapUrlGetFunc(txnp, &urlLoc); |
| 375 | if (rc != TS_SUCCESS) { |
| 376 | urlStrLen = sizeof(NotFound) - 1; |
| 377 | return NotFound; |
| 378 | } |
| 379 | |
| 380 | char *urlStr = TSUrlStringGet(nullptr, urlLoc, &urlStrLen); |
| 381 | |
| 382 | // Be defensive. |
| 383 | if ((urlStrLen == 0) and urlStr) { |
| 384 | TSError("[xdebug] non-null remap URL string with zero length"); |
| 385 | TSfree(urlStr); |
| 386 | urlStr = nullptr; |
| 387 | } |
| 388 | |
| 389 | if (!urlStr) { |
| 390 | urlStrLen = sizeof(NotFound) - 1; |
| 391 | return NotFound; |
| 392 | } |
| 393 | |
| 394 | return urlStr; |
| 395 | } |
| 396 | |
| 397 | static void |
| 398 | InjectRemapHeader(TSHttpTxn txn, TSMBuffer buffer, TSMLoc hdr) |
no test coverage detected