namespace Friendica\Network;
+use GuzzleHttp\Exception\TransferException;
+
/**
* Interface for calling HTTP requests and returning their responses
*/
* Send a HEAD to an URL.
*
* @param string $url URL to fetch
- * @param array $opts (optional parameters) assoziative array with:
- * 'accept_content' => supply Accept: header with 'accept_content' as the value
+ * @param array $opts (optional parameters) associative array with:
+ * 'accept_content' => (string array) supply Accept: header with 'accept_content' as the value
* 'timeout' => int Timeout in seconds, default system config value or 60 seconds
* 'cookiejar' => path to cookie jar file
* 'header' => header array
* Send a GET to an URL.
*
* @param string $url URL to fetch
- * @param array $opts (optional parameters) assoziative array with:
- * 'accept_content' => supply Accept: header with 'accept_content' as the value
+ * @param array $opts (optional parameters) associative array with:
+ * 'accept_content' => (string array) supply Accept: header with 'accept_content' as the value
* 'timeout' => int Timeout in seconds, default system config value or 60 seconds
* 'cookiejar' => path to cookie jar file
* 'header' => header array
*/
public function get(string $url, array $opts = []);
+ /**
+ * Sends a HTTP request to a given url
+ *
+ * @param string $method A HTTP request
+ * @param string $url Url to send to
+ * @param array $opts (optional parameters) associative array with:
+ * 'body' => (mixed) setting the body for sending data
+ * 'accept_content' => (string array) supply Accept: header with 'accept_content' as the value
+ * 'timeout' => int Timeout in seconds, default system config value or 60 seconds
+ * 'cookiejar' => path to cookie jar file
+ * 'header' => header array
+ * 'content_length' => int maximum File content length
+ * 'auth' => array authentication settings
+ *
+ * @return IHTTPResult
+ */
+ public function request(string $method, string $url, array $opts = []);
+
/**
* Send POST request to an URL
*
* through HTTP code or meta refresh tags. Stops after 10 redirections.
*
* @param string $url A user-submitted URL
- * @param int $depth The current redirection recursion level (internal)
- * @param bool $fetchbody Wether to fetch the body or not after the HEAD requests
*
* @return string A canonical URL
- * @throws \Friendica\Network\HTTPException\InternalServerErrorException
- * @see ParseUrl::getSiteinfo
*
- * @todo Remove the $fetchbody parameter that generates an extraneous HEAD request
+ * @throws TransferException In case there's an error during the resolving
*/
- public function finalUrl(string $url, int $depth = 1, bool $fetchbody = false);
+ public function finalUrl(string $url);
}