# LDEV-5387 / PR #3502: Redundant GET requests in HTTPResource fallback

**URL:** <https://dev.lucee.org/t/ldev-5387-pr-3502-redundant-get-requests-in-httpresource-fallback/17737>\
**Category:** hacking\
**Created:** [November 1, 2026, 7:33am UTC](https://dev.lucee.org/t/ldev-5387-pr-3502-redundant-get-requests-in-httpresource-fallback/17737 "2026-11-01T07:33:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![philsw](https://dev.lucee.org/letter_avatar_proxy/v4/letter/p/a183cd/32.png) [@philsw](https://dev.lucee.org/u/philsw)\
**Post date:** [November 1, 2026, 7:33am UTC](https://dev.lucee.org/t/ldev-5387-pr-3502-redundant-get-requests-in-httpresource-fallback/17737/1 "2026-11-01T07:33:16Z")

</div>

Following the recent merge of [PR #3502](https://github.com/lucee/Lucee/pull/3502) for [LDEV-5387](https://luceeserver.atlassian.net/browse/LDEV-5387), Tom Chiverton commented on Jira:

> _“Does this PR cause a double GET ? I don’t see it saving the response from the fall back GET to be used later”_

Looking at `HTTPResource.java`, Tom’s concern is valid — and depending on the operation, it can trigger up to **3 separate GET requests** and **2 HEAD requests** for a single tag/function call.

* * *

#### Where it happens

In [`core/.../HTTPResource.java`](https://github.com/lucee/Lucee/blob/7.1/core/src/main/java/lucee/commons/io/res/type/http/HTTPResource.java#L130-L141):

```java
if (rejectsHead(code)) {
    HTTPResponse rsp = null;
    try {
        rsp = HTTPEngine4Impl.get(url, data.username, data.password, _getTimeout(), true, null, data.userAgent, pd, null);
        code = rsp.getStatusCode();
    }
    finally {
        HTTPEngine.closeEL(rsp); // <--- Closed and discarded immediately
    }
}
headStatusCode = code;
return code;

```

The fallback GET in `getStatusCode()` reads the status, closes the connection in `finally`, and only records `headStatusCode = code`. Crucially, it does not assign `rsp` to `this.http`.

* * *

#### The request traces

1. **`fileRead(url)`**:

2. **`<cfcontent file="url">`** :

* * *

#### Why the test missed it

In `test/tickets/LDEV5387.cfc`, the mock server tracks requests via `attributes.requests.add(method & " " & path)`, but the spec only asserts:

```cfml
expect( trim( result.fileContent ) ).toBe( "LDEV-5387" );

```

There are no assertions checking `arrayLen(attributes.requests)` or verifying that only a single GET is issued.

* * *

#### Questions for the team / bot

1. Can we update `HTTPResource` to preserve `this.http` when the fallback GET succeeds, rather than closing it in `getStatusCode()`?
2. How should `HTTPResource.getInputStream()` handle reuse vs recreation (currently hardcoded as `getHTTPResponse(true)`) when an open response stream already exists on the resource?
3. Could we add a request-count assertion to `test/tickets/LDEV5387.cfc` to prevent multi-request regressions going forward?
4. is @GianTschingt configured to see replies on jira tickets? I also sent a PM on this forum but it wasn’t read, afaik.

---

<div class="post-metadata">

**Author:** ![GianTschingt](https://dev.lucee.org/user_avatar/dev.lucee.org/giantschingt/32/9300_2.png) [@GianTschingt](https://dev.lucee.org/u/GianTschingt)\
**Post date:** [November 2, 2026, 8:08am UTC](https://dev.lucee.org/t/ldev-5387-pr-3502-redundant-get-requests-in-httpresource-fallback/17737/2 "2026-11-02T08:08:37Z")

</div>

Thanks Phil, and Tom for spotting it. You’re right: the fallback GET only keeps the status code and throws away the response, so a server that rejects HEAD gets hit several times. We’ll fix it on 7.1 so the response from the fallback GET is reused instead of sending new requests, and we’ll add a request-count assertion to the LDEV-5387 test so this can’t come back unnoticed. The ticket is [Jira](https://luceeserver.atlassian.net/browse/LDEV-6821)

Jira comments do reach us. The forum is still the quickest way to get a reply, though.

---

<div class="post-metadata">

**Author:** ![charlottescott](https://dev.lucee.org/letter_avatar_proxy/v4/letter/c/c6cbf5/32.png) [@charlottescott](https://dev.lucee.org/u/charlottescott)\
**Post date:** [November 17, 2026, 2:19pm UTC](https://dev.lucee.org/t/ldev-5387-pr-3502-redundant-get-requests-in-httpresource-fallback/17737/3 "2026-11-17T14:19:39Z")

</div>

The fix should also pin down ownership of the cached fallback response: getStatusCode() must leave it open, and getInputStream() should reuse it without a second request, but the response still needs one deterministic close path. For the regression test, assert the exact method sequence for both the simple file read and the path, since the latter exposed the 2 HEAD + 3 GET case. Counting only GETs would miss duplicate HEADs.
