Subversion Repositories Applications.framework

Compare Revisions

Ignore whitespace Rev 256 → Rev 255

/trunk/framework/Client.php
13,18 → 13,12
*/
class Client {
const HTTP_URL_REQUETE_SEPARATEUR = '&';
private $http_methodes = array('GET', 'POST', 'PUT', 'DELETE', 'HEAD', 'OPTIONS', 'CONNECT', 'TRACE');
const HTTP_URL_REQUETE_CLE_VALEUR_SEPARATEUR = '=';
protected $parametres = null;
private $url = null;
private $reponse_entetes = null;
//+----------------------------------------------------------------------------------------------------------------+
// ACCESSEURS
public function getReponseEntetes($cle) {
return $this->reponse_entetes;
}
public function getParametre($cle) {
$valeur = (isset($this->parametres[$cle])) ? $this->parametres[$cle] : null;
return $valeur;
66,10 → 60,9
return $retour;
}
public function envoyerRequete($url, $mode, Array $donnees = array()) {
$this->url = $url;
private function envoyerRequete($url, $mode, Array $donnees = array()) {
$contenu = false;
if (! in_array($mode, $this->http_methodes)) {
if ($mode != 'GET' && $mode != 'PUT' && $mode != 'POST' && $mode != 'DELETE') {
$e = "Le mode de requête '$mode' n'est pas accepté!";
trigger_error($e, E_USER_WARNING);
} else {
80,12 → 73,13
'content' => http_build_query($donnees, null, self::HTTP_URL_REQUETE_SEPARATEUR))));
$flux = @fopen($url, 'r', false, $contexte);
if (!$flux) {
$this->reponse_entetes = $http_response_header;
$this->traiterEntete($http_response_header, $url);
$e = "L'ouverture de l'url '$url' par la méthode HTTP '$mode' a échoué!";
trigger_error($e, E_USER_WARNING);
} else {
// Informations sur les en-têtes et métadonnées du flux
$this->reponse_entetes = stream_get_meta_data($flux);
$entetes = stream_get_meta_data($flux);
$this->traiterEntete($entetes, $url);
// Contenu actuel de $url
$contenu = stream_get_contents($flux);
92,7 → 86,6
fclose($flux);
}
$this->traiterEntete();
}
$this->reinitialiser();
return $contenu;
110,14 → 103,13
return $url;
}
private function traiterEntete() {
$infos = $this->analyserEntete();
private function traiterEntete($entetes, $uri) {
$infos = $this->analyserEntete($entetes, $uri);
$this->traiterEnteteDebogage($infos);
}
private function analyserEntete() {
$entetes = $this->reponse_entetes;
$infos = array('date' => null, 'uri' => $this->url, 'debogages' => null);
private function analyserEntete($entetes, $uri) {
$infos = array('date' => null, 'uri' => $uri, 'debogages' => null);
if (isset($entetes['wrapper_data'])) {
$entetes = $entetes['wrapper_data'];
133,7 → 125,7
return $infos;
}
private function traiterEnteteDebogage($entetes_analyses) {
private function traiterEnteteDebogage($entetes) {
if (isset($entetes['debogages'])) {
$date = $entetes['date'];
$uri = $entetes['uri'];