Skip to content

Commit 961a8c7

Browse files
author
Michael Babker
committed
Use JHttp
1 parent 1873806 commit 961a8c7

File tree

2 files changed

+27
-199
lines changed

2 files changed

+27
-199
lines changed

administrator/components/com_patchtester/helpers/curl/curl.php

Lines changed: 0 additions & 195 deletions
This file was deleted.

administrator/components/com_patchtester/models/pull.php

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,31 @@
1414
*/
1515
class PatchtesterModelPull extends JModelLegacy
1616
{
17+
/**
18+
* @var JHttp
19+
*/
20+
protected $transport;
21+
22+
/**
23+
* Constructor
24+
*
25+
* @param array $config An array of configuration options (name, state, dbo, table_path, ignore_request).
26+
*
27+
* @since 12.2
28+
* @throws Exception
29+
*/
30+
public function __construct($config = array())
31+
{
32+
parent::__construct($config);
33+
34+
// Set up the JHttp object
35+
$options = new JRegistry;
36+
$options->set('userAgent', 'JPatchTester/1.0');
37+
$options->set('timeout', 120);
38+
39+
$this->transport = JHttpFactory::getHttp($options, 'curl');
40+
}
41+
1742
/**
1843
* Method to auto-populate the model state.
1944
*
@@ -104,8 +129,7 @@ public function apply($id)
104129
throw new Exception(JText::_('COM_PATCHTESTER_REPO_IS_GONE'));
105130
}
106131

107-
$patch = PTCurl::getAdapter($pull->diff_url)
108-
->fetch()->body;
132+
$patch = $this->transport->get($pull->diff_url)->body;
109133

110134
$files = $this->parsePatch($patch);
111135

@@ -132,8 +156,7 @@ public function apply($id)
132156
$url = 'https://raw.github.com/' . $pull->head->user->login . '/' . $pull->head->repo->name . '/' .
133157
$pull->head->ref . '/' . $file->new;
134158

135-
$file->body = PTCurl::getAdapter($url)
136-
->fetch()->body;
159+
$file->body = $this->transport->get($url)->body;
137160
}
138161
}
139162

0 commit comments

Comments
 (0)