I'd like to write Behat/Mink scenarios to check whether certain user accounts can download a large file. I can use the When I follow "largefile.zip"
event, but that appears to download the entire file.
Rather than wasting time and resources streaming the large file, I'd like to (for example) just check the result of an HTTP HEAD
request, or just try to start downloading the file with an HTTP GET
request and then cancel it immediately and check the response status code
.
How can I do that with Behat/Mink?
I agree with @NathanStretch regarding extending, so here's what i did.
This example is based on using http://download.thinkbroadband.com/5MB.zip as the download url. Not perfect since i don't see the file name in the response headers, but it does have Content Length.
With a .feature file that had the following:
If you have control over the downloads themselves then you can set the filename in the headers and check for that instead of the size. Certainly better if the size can be variable since i think that would mean having to split the content length string, converting to an int and then doing a comparison. Ugh. There's probably a more elegant solution to that.
Hope that helps somewhat.