ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Post.php
Go to the documentation of this file.
1 <?php
2 
71 {
72 
78  private $_contentType;
79 
85  private $_body;
86 
95  public function setContentType($contentType)
96  {
97  if ($this->hasBeenSent()) {
99  'Cannot set the content type, request already sent.'
100  );
101  }
102 
103  $this->_contentType = $contentType;
104  }
105 
114  public function setBody($body)
115  {
116  if ($this->hasBeenSent()) {
117  throw new CAS_OutOfSequenceException(
118  'Cannot set the body, request already sent.'
119  );
120  }
121 
122  $this->_body = $body;
123  }
124 
133  {
134  if (empty($this->_contentType) && !empty($this->_body)) {
136  "If you pass a POST body, you must specify a content type via "
137  . get_class($this) . '->setContentType($contentType).'
138  );
139  }
140 
141  $request->makePost();
142  if (!empty($this->_body)) {
143  $request->addHeader('Content-Type: ' . $this->_contentType);
144  $request->addHeader('Content-Length: ' . strlen($this->_body));
145  $request->setPostBody($this->_body);
146  }
147  }
148 }
setContentType($contentType)
Set the content type of this POST request.
Definition: Post.php:95
$_body
The body of the this request.
Definition: Post.php:85
foreach($paths as $path) $request
Definition: asyncclient.php:32
populateRequest(CAS_Request_RequestInterface $request)
Add any other parts of the request needed by concrete classes.
Definition: Post.php:132
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:78
hasBeenSent()
Answer true if our request has been sent yet.
Definition: Abstract.php:291
setBody($body)
Set the body of this POST request.
Definition: Post.php:114
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', mb_strtolower($path, 'UTF-8'))) $contentType
Definition: module.php:144
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.