mirror of
https://github.com/friendica/friendica
synced 2025-04-28 19:44:23 +02:00
Request type set for all HTTP requests
This commit is contained in:
parent
d788cb82cc
commit
5751e024c0
30 changed files with 129 additions and 90 deletions
|
@ -39,10 +39,11 @@ interface ICanSendHttpRequests
|
|||
* @param string $accept_content supply Accept: header with 'accept_content' as the value
|
||||
* @param int $timeout Timeout in seconds, default system config value or 60 seconds
|
||||
* @param string $cookiejar Path to cookie jar file
|
||||
* @param string $request Request Type
|
||||
*
|
||||
* @return string The fetched content
|
||||
*/
|
||||
public function fetch(string $url, string $accept_content = HttpClientAccept::DEFAULT, int $timeout = 0, string $cookiejar = ''): string;
|
||||
public function fetch(string $url, string $accept_content = HttpClientAccept::DEFAULT, int $timeout = 0, string $cookiejar = '', string $request = ''): string;
|
||||
|
||||
/**
|
||||
* Fetches the whole response of an URL.
|
||||
|
@ -54,10 +55,11 @@ interface ICanSendHttpRequests
|
|||
* @param string $accept_content supply Accept: header with 'accept_content' as the value
|
||||
* @param int $timeout Timeout in seconds, default system config value or 60 seconds
|
||||
* @param string $cookiejar Path to cookie jar file
|
||||
* @param string $request Request Type
|
||||
*
|
||||
* @return ICanHandleHttpResponses With all relevant information, 'body' contains the actual fetched content.
|
||||
*/
|
||||
public function fetchFull(string $url, string $accept_content = HttpClientAccept::DEFAULT, int $timeout = 0, string $cookiejar = ''): ICanHandleHttpResponses;
|
||||
public function fetchFull(string $url, string $accept_content = HttpClientAccept::DEFAULT, int $timeout = 0, string $cookiejar = '', string $request = ''): ICanHandleHttpResponses;
|
||||
|
||||
/**
|
||||
* Send a GET to a URL.
|
||||
|
|
|
@ -267,7 +267,7 @@ class HttpClient implements ICanSendHttpRequests
|
|||
|
||||
$url = trim($url, "'");
|
||||
|
||||
$this->resolver->setUserAgent($this->getUserAgent(HttpClientRequest::RESOLVER));
|
||||
$this->resolver->setUserAgent($this->getUserAgent(HttpClientRequest::URLRESOLVER));
|
||||
$urlResult = $this->resolver->resolveURL($url);
|
||||
|
||||
if ($urlResult->didErrorOccur()) {
|
||||
|
@ -280,9 +280,9 @@ class HttpClient implements ICanSendHttpRequests
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function fetch(string $url, string $accept_content = HttpClientAccept::DEFAULT, int $timeout = 0, string $cookiejar = ''): string
|
||||
public function fetch(string $url, string $accept_content = HttpClientAccept::DEFAULT, int $timeout = 0, string $cookiejar = '', string $request = ''): string
|
||||
{
|
||||
$ret = $this->fetchFull($url, $accept_content, $timeout, $cookiejar);
|
||||
$ret = $this->fetchFull($url, $accept_content, $timeout, $cookiejar, $request);
|
||||
|
||||
return $ret->getBodyString();
|
||||
}
|
||||
|
@ -290,14 +290,15 @@ class HttpClient implements ICanSendHttpRequests
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function fetchFull(string $url, string $accept_content = HttpClientAccept::DEFAULT, int $timeout = 0, string $cookiejar = ''): ICanHandleHttpResponses
|
||||
public function fetchFull(string $url, string $accept_content = HttpClientAccept::DEFAULT, int $timeout = 0, string $cookiejar = '', string $request = ''): ICanHandleHttpResponses
|
||||
{
|
||||
return $this->get(
|
||||
$url,
|
||||
$accept_content,
|
||||
[
|
||||
HttpClientOptions::TIMEOUT => $timeout,
|
||||
HttpClientOptions::COOKIEJAR => $cookiejar
|
||||
HttpClientOptions::COOKIEJAR => $cookiejar,
|
||||
HttpClientOptions::REQUEST => $request,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
|
|
@ -26,14 +26,23 @@ namespace Friendica\Network\HTTPClient\Client;
|
|||
*/
|
||||
class HttpClientRequest
|
||||
{
|
||||
public const ACTIVITYPUB = 'ActivityPub/1';
|
||||
public const CONTENTTYPE = 'ContentTypeChecker/1';
|
||||
public const DFRN = 'DFRN/1';
|
||||
public const DIASPORA = 'Diaspora/1';
|
||||
public const MAGICAUTH = 'MagicAuth/1';
|
||||
public const MEDIAPROXY = 'MediaProxy/1';
|
||||
public const SALMON = 'Salmon/1';
|
||||
public const PUBSUB = 'PubSub/1';
|
||||
public const RESOLVER = 'URLResolver/1';
|
||||
public const VERIFIER = 'URLVerifier/1';
|
||||
public const ACTIVITYPUB = 'ActivityPub/1';
|
||||
public const CONTACTINFO = 'ContactInfo/1';
|
||||
public const CONTACTDISCOVER = 'ContactDiscover/1';
|
||||
public const CONTACTVERIFIER = 'ContactVerifier/1';
|
||||
public const CONTENTTYPE = 'ContentTypeChecker/1';
|
||||
public const DFRN = 'DFRN/1';
|
||||
public const DIASPORA = 'Diaspora/1';
|
||||
public const FEEDFETCHER = 'FeedFetcher/1';
|
||||
public const MAGICAUTH = 'MagicAuth/1';
|
||||
public const MEDIAPROXY = 'MediaProxy/1';
|
||||
public const MEDIAVERIFIER = 'MediaVerifier/1';
|
||||
public const OSTATUS = 'OStatus/1';
|
||||
public const SALMON = 'Salmon/1';
|
||||
public const SERVERINFO = 'ServerInfo/1';
|
||||
public const SERVERDISCOVER = 'ServerDiscover/1';
|
||||
public const SITEINFO = 'SiteInfo/1';
|
||||
public const PUBSUB = 'PubSub/1';
|
||||
public const URLRESOLVER = 'URLResolver/1';
|
||||
public const URLVERIFIER = 'URLVerifier/1';
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue