Skip to content

Call request->getRemoteHost() can cause to stuck app #218

Closed

Description

@jakubboucek

Version: 3.0.5 - 3.1.6

Bug Description

Call $request->getRemoteHost() can stuck app, because remote host cane be unreacheable by reverse DNS or can have too long response.

Steps To Reproduce

use Nette\Http\Request;
$request = new Request(
            new Url('http://example.com'),
            [],
            [],
            [],
            [],
            [],
            '1.0.32.12', // some IP from location with slow reachability (china for example)
            null
        );
$request->getRemoteHost(); // this can to solve too long

Problem 2: Here is no way to force set null value to Request::$remoteHost and get it – it always call internally gethostbyaddr() function.

Expected Behavior

Request should by only dataobject without using any data from external source (DNS server).

The getter getRemoteHost() is also called when I need to modify Request object, for example:

function setRequestHeaders(Request $request, array $headers): self
    {
        $dolly = new Request(
            ($request->getUrl()),
            $request->getPost(),
            $request->getFiles(),
            $request->getCookies(),
            $headers,
            $request->getMethod(),
            $request->getRemoteAddress(),
            $threquestis->getRemoteHost(), // <--- stucked here
            function () {
                return $request->getRawBody();
            },
        );
        return $dolly;
    }

Possible Solution

Usually is Request object filled by RequestFactory and getters just only response. Looks good to trust Request::$remoteHost filled from RequestFactory and don't try to fetch it (here/again) from external source.

Activity

  1. dg commented on Nov 8, 2022

    @dg
    Member

    Probably the best solution would be to deprecate getRemoteHost().

  2. jakubboucek commented on Dec 4, 2022

    @jakubboucek
    ContributorAuthor

    @dg Díky! ❤️

  3. added a commit that references this issue on Dec 5, 2022
    788ddc4
  4. added a commit that references this issue on Dec 21, 2022
    c9253e9
  5. 40 remaining items

  6. added a commit that references this issue on Oct 30, 2025
    13487c1
  7. added 6 commits that reference this issue on Dec 27, 2025
    fc449ed
    4a72005
    7d52e1c
    93e069c
    31340dc
    2bcc845
  8. added a commit that references this issue on Feb 9, 2026
    f163851
  9. added a commit that references this issue on Mar 9, 2026
    0c86628
  10. added 4 commits that reference this issue on May 26, 2026
    2d87b25
    27c1e66
    f41401d
    6374250
  11. added 2 commits that reference this issue on Jun 12, 2026
    3b57e23
    1f4e22c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions