<commit_before><?php

namespace Crackle\Requests {

	use \InvalidArgumentException;

	/**
	 * Represents an HTTP request sent using the GET method.
	 * @author <NAME>
	 */
	class GETRequest extends Request {

		/**
		 * Set the URL this request will be sent to.
		 * @param string $url					The URL this request will be sent to.
		 * @throws \InvalidArgumentException	If the given URL is invalid.
		 */
		public function setUrl($url) {
			$parts = parse_url($url);
			if($parts === false) {
				throw new InvalidArgumentException('The supplied URL is invalid.');
			}

			if(isset($parts['query'])) {
				// extract GET parameters and add them as fields
				$params = array();
				parse_str($parts['query'], $params);
				foreach($params as $name => $value) {
					$this->addField($name, $value);
				}
			}

			// set the original URL without the parameters as the request URL
			parent::setUrl(sprintf('%s://%s%s', $parts['scheme'], $parts['host'], $parts['path']));
		}

		/**
		 * Initialise a new HTTP GET request.
		 * @param string $url			An optional URL to initialise with.<commit_msg>Fixed warning if GET and HEAD request URLs were not supplied with a path.<commit_after><?php

namespace Crackle\Requests {

	use \InvalidArgumentException;

	/**
	 * Represents an HTTP request sent using the GET method.
	 * @author <NAME>
	 */
	class GETRequest extends Request {

		/**
		 * Set the URL this request will be sent to.
		 * @param string $url					The URL this request will be sent to.
		 * @throws \InvalidArgumentException	If the given URL is invalid.
		 */
		public function setUrl($url) {
			$parts = parse_url($url);
			if($parts === false) {
				throw new InvalidArgumentException('The supplied URL is invalid.');
			}

			if(isset($parts['query'])) {
				// extract GET parameters and add them as fields
				$params = array();
				parse_str($parts['query'], $params);
				foreach($params as $name => $value) {
					$this->addField($name, $value);
				}
			}

			// if the URL contains a host with no trailing slash, this key will not exist
			if(!isset($parts['path'])) {
				$parts['path'] = '';
			}

			// set the original URL without the parameters as the request URL
			parent::setUrl(sprintf('%s://%s%s', $parts['scheme'], $parts['host'], $parts['path']));
		}

		/**
		 * Initialise a new HTTP GET request.
		 * @param string $url			An optional URL to initialise with.
{'fraction_non_alphanumeric': 0.13693467336683418, 'fraction_numerical': 0.0, 'mean_word_length': 3.1985940246045694, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, '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': '2606681', 'n_tokens_mistral': 820, 'n_tokens_neox': 678, 'n_words': 251}