Skip to content

Commit

Permalink
Use JHttp
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Babker committed Jul 12, 2013
1 parent 1873806 commit 961a8c7
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 199 deletions.
195 changes: 0 additions & 195 deletions administrator/components/com_patchtester/helpers/curl/curl.php

This file was deleted.

31 changes: 27 additions & 4 deletions administrator/components/com_patchtester/models/pull.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,31 @@
*/
class PatchtesterModelPull extends JModelLegacy
{
/**
* @var JHttp
*/
protected $transport;

/**
* Constructor
*
* @param array $config An array of configuration options (name, state, dbo, table_path, ignore_request).
*
* @since 12.2
* @throws Exception
*/
public function __construct($config = array())
{
parent::__construct($config);

// Set up the JHttp object
$options = new JRegistry;
$options->set('userAgent', 'JPatchTester/1.0');
$options->set('timeout', 120);

$this->transport = JHttpFactory::getHttp($options, 'curl');
}

/**
* Method to auto-populate the model state.
*
Expand Down Expand Up @@ -104,8 +129,7 @@ public function apply($id)
throw new Exception(JText::_('COM_PATCHTESTER_REPO_IS_GONE'));
}

$patch = PTCurl::getAdapter($pull->diff_url)
->fetch()->body;
$patch = $this->transport->get($pull->diff_url)->body;

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

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

$file->body = PTCurl::getAdapter($url)
->fetch()->body;
$file->body = $this->transport->get($url)->body;
}
}

Expand Down

0 comments on commit 961a8c7

Please sign in to comment.