laravelhttppostmanphpstormguzzle

Why do I get a timeout in PhpStorm HTTP Client and Laravel HTTP Client but not in Postman?


When I send a plain GET request with Postman this takes about 228ms consistently and yields a json response. As you can see I disabled cookies and headers in the request to have the exact same request. The generated curl seems to confirm this. Please have a better look at my first 2 screenshots of Postman for proof (I would doubt me as well). No headers at all, even in de 2nd image of the debug console you'll see no headers should be sent.

enter image description here

enter image description here

When I try the same thing with PhpStorm's HTTP client

I get a timeout (except for 1 time which worked after 30 seconds) enter image description here

Same thing in code:

$result = Http::timeout(10)
    ->get('https://mobileapi.jumbo.com/v17/products');


dump($result->body());

Making the request in curl is even weirder:

enter image description here

So we have 3 different responses for seemingly the same request:

Update Found a solution to my problem, but the reason why Postman works without it still baffles me: A User-Agent header containing exactly "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Firefox/102.0" works. However as you can see in above screenshots I don't send this header in Postman and there it works without. This question as to why this happens still stands.


Solution

  • Why do you get different behaviors using seemingly the same request? Surely, the web server has some request filtering rules based on HTTP headers.

    Even if it looks that all HTTP clients send the same request, the reality is that each one attaches slightly different headers silently. Given so, I created a RequestBin to check the differences between the clients.

    curl --location 'https://...'

    Host: envyr05unq3bk.x.pipedream.net
    X-Amzn-Trace-Id: Root=1-64a95ba2-4633081a75af397c63ece198
    User-Agent: curl/7.71.1
    Accept: */*
    

    Postman with Host header only

    Host: envyr05unq3bk.x.pipedream.net
    X-Amzn-Trace-Id: Root=1-64a95bac-102cc1e826a026f328c6c583
    

    PhpStorm HTTP Client

    Host: envyr05unq3bk.x.pipedream.net
    X-Amzn-Trace-Id: Root=1-64a95cc5-40d9098a346629e74f52f4d9
    User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.7)
    Accept-Encoding: br,deflate,gzip,x-gzip
    

    Checking against your domain, it seems that setting the User-Agent to curl/7.71.1 or Apache-HttpClient/4.5.14 (Java/17.0.7) causes a time-out. As mentioned in other responses, there is probably a blacklist for user agents.