<commit_before><?php
/* This class is part of the XP framework
 *
 * $Id$ 
 */

  $package= 'webservices.rest';

  /**
   * Represents output
   *
   */
  abstract class webservicesrestOutput extends Object {
    protected $status;
    protected $headers= array();
    protected $cookies= array();

    /**
     * Adds a header and returns this instance
     *
     * @param   string name
     * @param   string value
     * @return  self
     */
    public function withHeader($name, $value) {
      $this->headers[$name]= $value;
      return $this;
    }

    /**
     * Adds a cookie and returns this instance
     *
     * @param   scriptlet.Cookie cookie
     * @return  self
     */
    public function withCookie(Cookie $cookie) {
      $this->cookies[]= $cookie;
      return $this;
    }

    /**
     * Write response headers
     *
     * @param  scriptlet.Response response
     * @param  peer.URL base
     * @param  string format
     */
    protected abstract function writeHead($response, $base, $format);

    /**
     * Write response body
     *
     * @param  scriptlet.Response response
     * @param  peer.URL base
     * @param  string format
     */
    protected abstract function writeBody($response, $base, $format);

    /**
     *  this payload to an output stream
     *
     * @param  scriptlet.Response response
     * @param  peer.URL base
     * @param  string format
     * @return bool handled
     */
    public function writeTo($response, $base, $format) {
      $response->setStatus($this->status);
      $this->writeHead($response, $base, $format);

      // Headers
      foreach ($this->headers as $name => $value) {
        if ('Location' === $name) {
          $url= clone $base;
          $response->setHeader($name, $url->setPath($value)->getURL());
        } else {
          $response->setHeader($name, $value);
        }
      }
      foreach ($this->cookies as $cookie) {
        $response->setCookie($cookie);
      }

      $this->writeBody($response, $base, $format);
      return TRUE;
    }
  }<commit_msg>- QA: Apidocs<commit_after><?php
/* This class is part of the XP framework
 *
 * $Id$ 
 */

  $package= 'webservices.rest';

  /**
   * Represents output
   *
   */
  abstract class webservicesrestOutput extends Object {
    protected $status;
    protected $headers= array();
    protected $cookies= array();

    /**
     * Adds a header and returns this instance
     *
     * @param   string name
     * @param   string value
     * @return  self
     */
    public function withHeader($name, $value) {
      $this->headers[$name]= $value;
      return $this;
    }

    /**
     * Adds a cookie and returns this instance
     *
     * @param   scriptlet.Cookie cookie
     * @return  self
     */
    public function withCookie(Cookie $cookie) {
      $this->cookies[]= $cookie;
      return $this;
    }

    /**
     * Write response headers
     *
     * @param  scriptlet.Response response
     * @param  peer.URL base
     * @param  string format
     */
    protected abstract function writeHead($response, $base, $format);

    /**
     * Write response body
     *
     * @param  scriptlet.Response response
     * @param  peer.URL base
     * @param  string format
     */
    protected abstract function writeBody($response, $base, $format);

    /**
     * Write this output to the scriptlet's response
     *
     * @param  scriptlet.Response response
     * @param  peer.URL base
     * @param  string format
     * @return bool handled
     */
    public function writeTo($response, $base, $format) {
      $response->setStatus($this->status);
      $this->writeHead($response, $base, $format);

      // Headers
      foreach ($this->headers as $name => $value) {
        if ('Location' === $name) {
          $url= clone $base;
          $response->setHeader($name, $url->setPath($value)->getURL());
        } else {
          $response->setHeader($name, $value);
        }
      }
      foreach ($this->cookies as $cookie) {
        $response->setCookie($cookie);
      }

      $this->writeBody($response, $base, $format);
      return TRUE;
    }
  }
{'fraction_non_alphanumeric': 0.13273694390715668, 'fraction_numerical': 0.0, 'mean_word_length': 2.1246223564954683, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6737775', 'n_tokens_mistral': 1219, 'n_tokens_neox': 1194, 'n_words': 323}