<commit_before><?php

namespace SimplyTestable\WebClientBundle\Services;

use webignition\InternetMediaType\Parser\Parser as InternetMediaTypeParser;
use SimplyTestable\WebClientBundle\Exception\WebResourceException;

class WebResourceService {    
    
    /**
     *
     * @var \SimplyTestable\WebClientBundle\Services\HttpClientService
     */
    private $httpClientService;
    
    
    /**
     * Maps content types to WebResource subclasses
     * 
     * @var array
     */
    private $contentTypeWebResourceMap = array();
    
    
    /**
     *
     * @param \SimplyTestable\WebClientBundle\Services\HttpClientService $httpClientService
     * @param array $contentTypeWebResourceMap
     */
    public function __construct(
            \SimplyTestable\WebClientBundle\Services\HttpClientService $httpClientService,
            $contentTypeWebResourceMap)
    {
        $this->httpClientService = $httpClientService;        
        $this->contentTypeWebResourceMap = $contentTypeWebResourceMap;        
    }
    
    
    /**
     * 
     * @return \SimplyTestable\WebClientBundle\Services\HttpClientService
     */
    public function getHttpClientService() {        
        return $this->httpClientService;
    }
    
    
    /**
     * 
     * @param \Guzzle\Http\Message\Request $request
     * @return \SimplyTestable\WebClientBundle\Services\webResourceClassName
     * @throws WebResourceException
     */
    public function get(\Guzzle\Http\Message\Request $request) {        
        // Guzzle seems to be flailing in errors if redirects total more than 4
        $request->getParams()->set('redirect.max', 4);
        
        try {
            $response = $request->send();
        } catch (\Guzzle\Http\Exception\ServerErrorResponseException $serverErrorResponseException) {
            $response = $serverErrorResponseException->getResponse();
        } catch (\Guzzle\Http\Exception\ClientErrorResponseException $clientErrorResponseException) {
            $response = $clientErrorResponseException->getResponse();
        }
        
        if ($response->isInformational()) {
            // Interesting to see what makes this happen
            return;
        }
        
        if ($response->isRedirect()) {<commit_msg>Also dump out request URL to see where tests are failing<commit_after><?php

namespace SimplyTestable\WebClientBundle\Services;

use webignition\InternetMediaType\Parser\Parser as InternetMediaTypeParser;
use SimplyTestable\WebClientBundle\Exception\WebResourceException;

class WebResourceService {    
    
    /**
     *
     * @var \SimplyTestable\WebClientBundle\Services\HttpClientService
     */
    private $httpClientService;
    
    
    /**
     * Maps content types to WebResource subclasses
     * 
     * @var array
     */
    private $contentTypeWebResourceMap = array();
    
    
    /**
     *
     * @param \SimplyTestable\WebClientBundle\Services\HttpClientService $httpClientService
     * @param array $contentTypeWebResourceMap
     */
    public function __construct(
            \SimplyTestable\WebClientBundle\Services\HttpClientService $httpClientService,
            $contentTypeWebResourceMap)
    {
        $this->httpClientService = $httpClientService;        
        $this->contentTypeWebResourceMap = $contentTypeWebResourceMap;        
    }
    
    
    /**
     * 
     * @return \SimplyTestable\WebClientBundle\Services\HttpClientService
     */
    public function getHttpClientService() {        
        return $this->httpClientService;
    }
    
    
    /**
     * 
     * @param \Guzzle\Http\Message\Request $request
     * @return \SimplyTestable\WebClientBundle\Services\webResourceClassName
     * @throws WebResourceException
     */
    public function get(\Guzzle\Http\Message\Request $request) {
        var_dump($request->getUrl());
        
        // Guzzle seems to be flailing in errors if redirects total more than 4
        $request->getParams()->set('redirect.max', 4);
        
        try {
            $response = $request->send();
        } catch (\Guzzle\Http\Exception\ServerErrorResponseException $serverErrorResponseException) {
            $response = $serverErrorResponseException->getResponse();
        } catch (\Guzzle\Http\Exception\ClientErrorResponseException $clientErrorResponseException) {
            $response = $clientErrorResponseException->getResponse();
        }
        
        if ($response->isInformational()) {
            // Interesting to see what makes this happen
            return;
        }
        
        if ($response->isRedirect()) {
{'fraction_non_alphanumeric': 0.09442993907745866, 'fraction_numerical': 0.0008703220191470844, 'mean_word_length': 2.4460269865067468, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3315970', 'n_tokens_mistral': 1206, 'n_tokens_neox': 1182, 'n_words': 211}