php - How to prevent an intercepted Guzzle 3 request from generating DNS requests? -


I am using Goutte 1.0.6 (to use latest Gazelle 3) to create web scraper. For testing, I want to load an HTTP response and serve instead of a real cURL response, and it works mostly well. Currently the case of use is a unit test, but I hope I can do it for production caching too. Would like to use

Interesting, I have noticed that if I have been disconnected from the web, then my unit testing is slow down. I did an auspicious excavation with the virushark and found that my call for http://example.com/someething is generating DNS requests, though they are unnecessary.

Here is the relevant snippet of my ghazal plugin to give fake feedback here. The related bits have been captured on the request.before_send event, and the fact is that its response is finally filled in, if any cache items are projected into the table:

  class savedPageLoaderPlugin HttpPluginBase {Public Static Function receives subscribedEvents () {Returns array ('request.before_send' => 'onRequestBeforeSend',); } / ** * A gazelle handles events before attempting an HTTP session * * @ ultimate \ ghazal \ common \ event $ event * @ throws \ webcracker \ PauseException * / public function before security (event $ event) {// @ $ $ request garrison \ hpp \ message \ response $ request = $ event ['request']; // If we are caching for this run then decide that (! $ This- & gt; isLoadEnabled ()) {return; } // If we have a URL for this request, then decide $ url = $ request- & gt; GetUrl (); $ HttpPage = HttpPageQuery :: Create () - & gt; FilterByUrl ($ url) - & gt; Find one (); If (! $ HttpPage) {return; } // Set up a notification message for all customers, then set the response $ -This-> SetContainerMessage (auto :: MESSAGE_USES_SAVED_PAGE); $ Response = new response (200, $ this- & gt; Converters Intocardable ($ httpPage-> getHeaders ()), $ httpPage-> getBody ()); $ Request & gt; SetResponse ($ response); }  

To recover the code, the code itself is working. Virus does not show any real effort to get data on Horror Port 80, and for example, a related failure exception (e.g. 404) inability to supply the documents related to it. Therefore, my counterfeit reactions seem fine.

Is there any way to stop Ghazal from calling this useless DNS call? I had thought about using it, but I was not sure how to do this at the time, nor any time it could fix the remaining problem.

(I like the fake / joke plugin inside someone, so when I do not have any problem using the mock plugins , then I would rather intercept the docks than the outside I think I can raise it, maybe?)

It may be that I need to go to the later version of the ghazal, and if this is the only way, then it should be so. . I am on an old project where the latest Gautale used Gajle 3. I intend to upgrade, but if possible then I would like to do it, because whatever I want to do to my current versions.


Post Script: It happens to me that the DNS call can not come from Gautav and does not sound. I'm not sure how to go about debugging, at least one part because Goutte is brought as a .phar file by the composer Debugger like xdebug can be useful here to see if the network is making calls, and where?

Ah: it was neither ghazal nor cow nor in my code, I used to log in to HTTP logging Prevent the request.success event for purposes. Here I call gethostbyname () , which aims to do DNS lookup.

It is now disabled, "mysterious" DNS calls have disappeared.


Comments