phpCAS  version 1.4.0
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)
Definition: Post.php:96
$_body
Definition: Post.php:86
populateRequest(CAS_Request_RequestInterface $request)
Definition: Post.php:133
$_contentType
Definition: Post.php:79
setBody($body)
Definition: Post.php:115
Definition: Post.php:70