ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
Post.php
Go to the documentation of this file.
1 <?php
2 
72 {
73 
79  private $_contentType;
80 
86  private $_body;
87 
96  public function setContentType ($contentType)
97  {
98  if ($this->hasBeenSent()) {
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)) {
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 ?>
setContentType($contentType)
Set the content type of this POST request.
Definition: Post.php:96
$_body
The body of the this request.
Definition: Post.php:86
populateRequest(CAS_Request_RequestInterface $request)
Add any other parts of the request needed by concrete classes.
Definition: Post.php:133
An Exception for problems communicating with a proxied service.
Definition: Exception.php:40
This interface defines a class library for performing web requests.
setPostBody($body)
Add a POST body to the request.
makePost()
Make the request a POST request rather than the default GET request.
This class defines Exceptions that should be thrown when the sequence of operations is invalid...
$_contentType
The content-type of this request.
Definition: Post.php:79
hasBeenSent()
Answer true if our request has been sent yet.
Definition: Abstract.php:292
setBody($body)
Set the body of this POST request.
Definition: Post.php:115
This class implements common methods for ProxiedService implementations included with phpCAS...
Definition: Abstract.php:41
if($path[strlen($path) - 1]==='/') if(is_dir($path)) if(!file_exists($path)) if(preg_match('#\.php$#D', $path)) $contentType
Definition: module.php:142
This class is used to make proxied service requests via the HTTP POST method.
Definition: Post.php:70
addHeader($header)
Add a header string to the request.