Page MenuHomeMiraheze

RottenLinks should use HttpRequestFactory
Closed, DuplicatePublic

Description

MediaWiki offers the HttpRequestFactory class to make HTTP calls in a standardised manner. The class ensures MediaWiki's internal logging features (e.g. 'http' log channel) and configurations settings (e.g. http_proxy) are used upon executing HTTP calls. Instead, RottenLinks uses the curl_ functions directly.

Example code (untested!):

$request = MediaWikiServices::getInstance()->getHttpRequestFactory()->create(
	$url,
	[ 
		'method' => 'HEAD', // return headers only
		'timeout' => $config->get( 'RottenLinksCurlTimeout' ),
		'userAgent' => 'RottenLinks, MediaWiki extension (https://github.com/miraheze/RottenLinks), running on ' . $config->get( 'Server' )
	],
	__METHOD__
)->execute();

return (int)$request->getStatus();

Event Timeline

Southparkfan triaged this task as Normal priority.May 13 2021, 17:13
Southparkfan created this task.

Usually we don't tag Extensions when tagging an additional Miraheze extension tag.

John added a subscriber: John.

Above task was created for this purpose, which was to overhaul how the detection works.