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