Example #1
0
 /**
  * Set body
  *
  * @param   string data
  */
 public function setBody($data)
 {
     parent::setBody($data);
     if ($this->hasHeader(Header::CONTENTLENGTH)) {
         $this->addHeader(Header::CONTENTLENGTH, strlen($this->body));
     }
 }
Example #2
0
 /**
  * Retrieve headers
  *
  * @return  <string,string>[]
  */
 public function getHeaders()
 {
     $hdrs = [];
     $hdrs[Header::ACCEPTVERSION] = implode(',', $this->versions);
     $hdrs[Header::HOST] = $this->host;
     if (null !== $this->user) {
         $hdrs[Header::LOGIN] = $this->user;
         if (null !== $this->pass) {
             $hdrs[Header::PASSCODE] = $this->pass;
         }
     }
     return array_merge($hdrs, parent::getHeaders());
 }
Example #3
0
 /**
  * Send a frame to server
  *
  * This is a low-level protocol function.
  *
  * @param   peer.stomp.frame.Frame frame
  * @return  peer.stomp.Frame or null
  */
 public function sendFrame(Frame $frame)
 {
     // Trace
     if ($this->cat) {
         $mo = new MemoryOutputStream();
         $frame->write(new StringWriter($mo));
         $this->debug('>>>', $mo->getBytes());
     }
     $frame->write($this->out);
     if ($frame->requiresImmediateResponse()) {
         return $this->recvFrame();
     }
     return null;
 }