Overview

Packages

  • CONTENIDO
  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentRssCreator
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
    • ScriptCookieDirective
  • mpAutoloaderClassMap
  • None
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • SearchSolr
    • SmartyWrapper
    • UrlShortener
    • UserForum
    • Workflow
  • PluginManager
  • Setup
    • Form
    • GUI
    • Helper
      • Environment
      • Filesystem
      • MySQL
      • PHP
    • UpgradeJob

Classes

  • cHttpRequest
  • cHttpRequestCurl
  • cHttpRequestSocket
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
  1: <?php
  2: 
  3: /**
  4:  * This file contains the the general HttpRequest class
  5:  * Extends this class and implement the functions to use
  6:  * other methods of doing HTTP requests
  7:  *
  8:  * @package Core
  9:  * @subpackage Core
 10:  * @version SVN Revision $Rev:$
 11:  *
 12:  * @author Mischa Holz
 13:  * @copyright four for business AG <www.4fb.de>
 14:  * @license http://www.contenido.org/license/LIZENZ.txt
 15:  * @link http://www.4fb.de
 16:  * @link http://www.contenido.org
 17:  */
 18: 
 19: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
 20: 
 21: /**
 22:  * Abstract HttpRequest class
 23:  *
 24:  * @package Core
 25:  * @subpackage Core
 26:  */
 27: abstract class cHttpRequest {
 28: 
 29:     /**
 30:      * Creates a new cHttpRequest object. The function determines the best
 31:      * extension to use and returns an object accordingly
 32:      *
 33:      * @param string $url [optional]
 34:      *         URL of the HTTP request
 35:      * @return cHttpRequest
 36:      */
 37:     public static function getHttpRequest($url = '') {
 38:         $className = 'cHttpRequestCurl';
 39:         if (!function_exists('curl_exec') || CURLOPT_RETURNTRANSFER != 19913) {
 40:             $className = 'cHttpRequestSocket';
 41:         }
 42: 
 43:         return new $className($url);
 44:     }
 45: 
 46:     /**
 47:      * Basic constructor
 48:      *
 49:      * @param string $url [optional]
 50:      *         URL of the HTTP request
 51:      */
 52:     abstract public function __construct($url = '');
 53: 
 54:     /**
 55:      * Peform the request using POST
 56:      *
 57:      * @param bool $return [optional]
 58:      *         If true, response of the server gets returned as string
 59:      * @param bool $returnHeaders [optional]
 60:      *         If true, headers will be included in the response
 61:      * @return string|bool
 62:      *         False on error, response otherwise
 63:      */
 64:     abstract public function postRequest($return = true, $returnHeaders = false);
 65: 
 66:     /**
 67:      * Peform the request using GET
 68:      *
 69:      * @param bool $return [optional]
 70:      *         If true, response of the server gets returned as string
 71:      * @param bool $returnHeaders [optional]
 72:      *         If true, headers will be included in the response
 73:      * @return string|bool
 74:      *         False on error, response otherwise
 75:      */
 76:     abstract public function getRequest($return = true, $returnHeaders = false);
 77: 
 78:     /**
 79:      * Peform the request using POST AND append all GET parameters
 80:      *
 81:      * @param bool $return [optional]
 82:      *         If true, response of the server gets returned as string
 83:      * @param bool $returnHeaders [optional]
 84:      *         If true, headers will be included in the response
 85:      * @return string|bool
 86:      *         False on error, response otherwise
 87:      */
 88:     abstract public function request($return = true, $returnHeaders = false);
 89: 
 90:     /**
 91:      * Set the GET parameters
 92:      *
 93:      * @param array $array
 94:      *         associative array containing keys and values of the GET parameters
 95:      * @return cHttpRequest
 96:      */
 97:     abstract public function setGetParams($array);
 98: 
 99:     /**
100:      * Set the POST parameters
101:      *
102:      * @param array $array
103:      *         associative array containing keys and values of the POST parameters
104:      * @return cHttpRequest
105:      */
106:     abstract public function setPostParams($array);
107: 
108:     /**
109:      * Set the HTTP headers
110:      *
111:      * @param array $array
112:      *         associative array containing the HTTP headers
113:      * @return cHttpRequest
114:      */
115:     abstract public function setHeaders($array);
116: 
117:     /**
118:      * Set the request URL
119:      *
120:      * @param string $url
121:      *         the URL
122:      * @return cHttpRequest
123:      */
124:     abstract public function setURL($url);
125: }
126: 
CMS CONTENIDO 4.9.8 API documentation generated by ApiGen 2.8.0