phpCAS version 1.3.6

Post.php
Go to the documentation of this file.
1 <?php
2
70 class CAS_ProxiedService_Http_Post
71 extends CAS_ProxiedService_Http_Abstract
72 {
73
79 private $_contentType;
80
86 private $_body;
87
96 public function setContentType ($contentType)
97 {
98 if ($this->hasBeenSent()) {
99 throw new CAS_OutOfSequenceException(
100 'Cannot set the content type, request already sent.'
101 );
102 }
103
104 $this->_contentType = $contentType;
105 }
106
115 public function setBody ($body)
116 {
117 if ($this->hasBeenSent()) {
118 throw new CAS_OutOfSequenceException(
119 'Cannot set the body, request already sent.'
120 );
121 }
122
123 $this->_body = $body;
124 }
125
133 protected function populateRequest (CAS_Request_RequestInterface $request)
134 {
135 if (empty($this->_contentType) && !empty($this->_body)) {
136 throw new CAS_ProxiedService_Exception(
137 "If you pass a POST body, you must specify a content type via "
138 .get_class($this).'->setContentType($contentType).'
139 );
140 }
141
142 $request->makePost();
143 if (!empty($this->_body)) {
144 $request->addHeader('Content-Type: '.$this->_contentType);
145 $request->addHeader('Content-Length: '.strlen($this->_body));
146 $request->setPostBody($this->_body);
147 }
148 }
149
150
151 }
152 ?>
CAS_ProxiedService_Http_Post\setContentType
setContentType($contentType)
Definition: Post.php:96
CAS_ProxiedService_Http_Post\$_body
$_body
Definition: Post.php:86
CAS_ProxiedService_Http_Post\populateRequest
populateRequest(CAS_Request_RequestInterface $request)
Definition: Post.php:133
CAS_ProxiedService_Exception
Definition: Exception.php:40
CAS_Request_RequestInterface
Definition: RequestInterface.php:40
CAS_Request_RequestInterface\setPostBody
setPostBody($body)
CAS_Request_RequestInterface\makePost
makePost()
CAS_OutOfSequenceException
Definition: OutOfSequenceException.php:44
CAS_ProxiedService_Http_Post\$_contentType
$_contentType
Definition: Post.php:79
CAS_ProxiedService_Http_Abstract\hasBeenSent
hasBeenSent()
Definition: Abstract.php:292
CAS_ProxiedService_Http_Post\setBody
setBody($body)
Definition: Post.php:115
CAS_ProxiedService_Http_Abstract
Definition: Abstract.php:41
CAS_ProxiedService_Http_Post
Definition: Post.php:70
CAS_Request_RequestInterface\addHeader
addHeader($header)