ILIAS  release_7 Revision v7.30-3-g800a261c036
Post.php
Go to the documentation of this file.
1<?php
2
71{
72
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()) {
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}
An exception for terminatinating execution or to throw for unit testing.
This class defines Exceptions that should be thrown when the sequence of operations is invalid.
An Exception for problems communicating with a proxied service.
Definition: Exception.php:41
This class implements common methods for ProxiedService implementations included with phpCAS.
Definition: Abstract.php:42
hasBeenSent()
Answer true if our request has been sent yet.
Definition: Abstract.php:291
This class is used to make proxied service requests via the HTTP POST method.
Definition: Post.php:71
$_body
The body of the this request.
Definition: Post.php:85
setContentType($contentType)
Set the content type of this POST request.
Definition: Post.php:95
populateRequest(CAS_Request_RequestInterface $request)
Add any other parts of the request needed by concrete classes.
Definition: Post.php:132
$_contentType
The content-type of this request.
Definition: Post.php:78
setBody($body)
Set the body of this POST request.
Definition: Post.php:114
This interface defines a class library for performing web requests.
makePost()
Make the request a POST request rather than the default GET request.
addHeader($header)
Add a header string to the request.
setPostBody($body)
Add a POST body to the request.