text:
"use strict";

// Extracted from https://github.com/jshint/jshint/blob/master/src/vars.js.

// Identifiers provided by the ECMAScript standard.

/*
    If the value is a boolean, it indicates whether the global is writable.

    If the value is an object, it should contain 'writable' and 'ignoreShadow'
    boolean properties. If 'ignoreShadow' is true, local vars that shadow the
    global will not generate a warning.
*/

exports.reserved = {
    arguments: false,
    NaN: false,
    break: false,
    continue: false,
    delete: false,
    do: false,
    new: false,
    undefined: false
};

exports.ecmaIdentifiers = {
    Array: false,
    Boolean: false,
    Date: false,
    decodeURI: false,
    decodeURIComponent: false,
    encodeURI: false,
    encodeURIComponent: false,
    Error: false,
    eval: false,
    EvalError: false,
    Function: false,
    hasOwnProperty: false,
    isFinite: false,
    isNaN: false,
    JSON: false,
    Math: false,
    Number: false,
    Object: false,
    parseInt: false,
    parseFloat: false,
    RangeError: false,
    ReferenceError: false,
    RegExp: false,
    String: false,
    SyntaxError: false,
    TypeError: false,
    URIError: false,
};

exports.newEcmaIdentifiers = {
    Set: false,
    Map: false,
    WeakMap: false,
    WeakSet: false,
    Proxy: false,
    Promise: false
};

// Global variables commonly provided by a web browser environment.

exports.browser = {
    Audio: false,
    Blob: false,
    addEventListener: false,
    applicationCache: false,
    atob: false,
    blur: { writable: false, ignoreShadow: true },
    btoa: false,
    cancelAnimationFrame: false,
    CanvasGradient: false,
    CanvasPattern: false,
    CanvasRenderingContext2D: false,
    clearInterval: false,
    clearTimeout: false,
    close: false,
    closed: { writable: false, ignoreShadow: true },
    CustomEvent: false,
    DOMParser: false,
    defaultStatus: false,
    document: { writable: false, ignoreShadow: true },
    Element: false,
    ElementTimeControl: false,
    Event: false,
    event: false,
    FileReader: false,
    FormData: false,
    focus: false,
    frames: false,
    getComputedStyle: false,
    HTMLElement: false,
    HTMLAnchorElement: false,
    HTMLBaseElement: false,
    HTMLBlockquoteElement: false,
    HTMLBodyElement: false,
    HTMLBRElement: false,
    HTMLButtonElement: false,
    HTMLCanvasElement: false,
    HTMLDirectoryElement: false,
    HTMLDivElement: false,
    HTMLDListElement: false,
    HTMLFieldSetElement: false,
    HTMLFontElement: false,
    HTMLFormElement: false,
    HTMLFrameElement: false,
    HTMLFrameSetElement: false,
    HTMLHeadElement: false,
    HTMLHeadingElement: false,
    HTMLHRElement: false,
    HTMLHtmlElement: false,
    HTMLIFrameElement: false,
    HTMLImageElement: false,
    HTMLInputElement: false,
    HTMLIsIndexElement: false,
    HTMLLabelElement: false,
    HTMLLayerElement: false,
    HTMLLegendElement: false,
    HTMLLIElement: false,
    HTMLLinkElement: false,
    HTMLMapElement: false,
    HTMLMenuElement: false,
    HTMLMetaElement: false,
    HTMLModElement: false,
    HTMLObjectElement: false,
    HTMLOListElement: false,
    HTMLOptGroupElement: false,
    HTMLOptionElement: false,
    HTMLParagraphElement: false,
    HTMLParamElement: false,
    HTMLPreElement: false,
    HTMLQuoteElement: false,
    HTMLScriptElement: false,
    HTMLSelectElement: false,
    HTMLStyleElement: false,
    HTMLTableCaptionElement: false,
    HTMLTableCellElement: false,
    HTMLTableColElement: false,
    HTMLTableElement: false,
    HTMLTableRowElement: false,
    HTMLTableSectionElement: false,
    HTMLTextAreaElement: false,
    HTMLTitleElement: false,
    HTMLUListElement: false,
    HTMLVideoElement: false,
    history: { writable: false, ignoreShadow: true },
    Image: false,
    length: { writable: false, ignoreShadow: true },
    localStorage: false,
    location: { writable: false, ignoreShadow: true },
    matchMedia: false,
    MessageChannel: false,
    MessageEvent: false,
    MessagePort: false,
    MouseEvent: false,
    moveBy: false,
    moveTo: false,
    MutationObserver: false,
    name: { writable: false, ignoreShadow: true },
    Node: false,
    NodeFilter: false,
    NodeList: false,
    navigator: false,
    onbeforeunload: true,
    onblur: true,
    onerror: true,
    onfocus: true,
    onload: true,
    onresize: true,
    onunload: true,
    open: false,
    openDatabase: false,
    opener: false,
    Option: false,
    parent: { writable: false, ignoreShadow: true },
    print: false,
    requestAnimationFrame: false,
    removeEventListener: false,
    resizeBy: false,
    resizeTo: false,
    screen: false,
    scroll: false,
    scrollBy: false,
    scrollTo: false,
    sessionStorage: false,
    setInterval: false,
    setTimeout: false,
    SharedWorker: false,
    status: { writable: false, ignoreShadow: true },
    SVGAElement: false,
    SVGAltGlyphDefElement: false,
    SVGAltGlyphElement: false,
    SVGAltGlyphItemElement: false,
    SVGAngle: false,
    SVGAnimateColorElement: false,
    SVGAnimateElement: false,
    SVGAnimateMotionElement: false,
    SVGAnimateTransformElement: false,
    SVGAnimatedAngle: false,
    SVGAnimatedBoolean: false,
    SVGAnimatedEnumeration: false,
    SVGAnimatedInteger: false,
    SVGAnimatedLength: false,
    SVGAnimatedLengthList: false,
    SVGAnimatedNumber: false,
    SVGAnimatedNumberList: false,
    SVGAnimatedPathData: false,
    SVGAnimatedPoints: false,
    SVGAnimatedPreserveAspectRatio: false,
    SVGAnimatedRect: false,
    SVGAnimatedString: false,
    SVGAnimatedTransformList: false,
    SVGAnimationElement: false,
    SVGCSSRule: false,
    SVGCircleElement: false,
    SVGClipPathElement: false,
    SVGColor: false,
    SVGColorProfileElement: false,
    SVGColorProfileRule: false,
    SVGComponentTransferFunctionElement: false,
    SVGCursorElement: false,
    SVGDefsElement: false,
    SVGDescElement: false,
    SVGDocument: false,
    SVGElement: false,
    SVGElementInstance: false,
    SVGElementInstanceList: false,
    SVGEllipseElement: false,
    SVGExternalResourcesRequired: false,
    SVGFEBlendElement: false,
    SVGFEColorMatrixElement: false,
    SVGFEComponentTransferElement: false,
    SVGFECompositeElement: false,
    SVGFEConvolveMatrixElement: false,
    SVGFEDiffuseLightingElement: false,
    SVGFEDisplacementMapElement: false,
    SVGFEDistantLightElement: false,
    SVGFEFloodElement: false,
    SVGFEFuncAElement: false,
    SVGFEFuncBElement: false,
    SVGFEFuncGElement: false,
    SVGFEFuncRElement: false,
    SVGFEGaussianBlurElement: false,
    SVGFEImageElement: false,
    SVGFEMergeElement: false,
    SVGFEMergeNodeElement: false,
    SVGFEMorphologyElement: false,
    SVGFEOffsetElement: false,
    SVGFEPointLightElement: false,
    SVGFESpecularLightingElement: false,
    SVGFESpotLightElement: false,
    SVGFETileElement: false,
    SVGFETurbulenceElement: false,
    SVGFilterElement: false,
    SVGFilterPrimitiveStandardAttributes: false,
    SVGFitToViewBox: false,
    SVGFontElement: false,
    SVGFontFaceElement: false,
    SVGFontFaceFormatElement: false,
    SVGFontFaceNameElement: false,
    SVGFontFaceSrcElement: false,
    SVGFontFaceUriElement: false,
    SVGForeignObjectElement: false,
    SVGGElement: false,
    SVGGlyphElement: false,
    SVGGlyphRefElement: false,
    SVGGradientElement: false,
    SVGHKernElement: false,
    SVGICCColor: false,
    SVGImageElement: false,
    SVGLangSpace: false,
    SVGLength: false,
    SVGLengthList: false,
    SVGLineElement: false,
    SVGLinearGradientElement: false,
    SVGLocatable: false,
    SVGMPathElement: false,
    SVGMarkerElement: false,
    SVGMaskElement: false,
    SVGMatrix: false,
    SVGMetadataElement: false,
    SVGMissingGlyphElement: false,
    SVGNumber: false,
    SVGNumberList: false,
    SVGPaint: false,
    SVGPathElement: false,
    SVGPathSeg: false,
    SVGPathSegArcAbs: false,
    SVGPathSegArcRel: false,
    SVGPathSegClosePath: false,
    SVGPathSegCurvetoCubicAbs: false,
    SVGPathSegCurvetoCubicRel: false,
    SVGPathSegCurvetoCubicSmoothAbs: false,
    SVGPathSegCurvetoCubicSmoothRel: false,
    SVGPathSegCurvetoQuadraticAbs: false,
    SVGPathSegCurvetoQuadraticRel: false,
    SVGPathSegCurvetoQuadraticSmoothAbs: false,
    SVGPathSegCurvetoQuadraticSmoothRel: false,
    SVGPathSegLinetoAbs: false,
    SVGPathSegLinetoHorizontalAbs: false,
    SVGPathSegLinetoHorizontalRel: false,
    SVGPathSegLinetoRel: false,
    SVGPathSegLinetoVerticalAbs: false,
    SVGPathSegLinetoVerticalRel: false,
    SVGPathSegList: false,
    SVGPathSegMovetoAbs: false,
    SVGPathSegMovetoRel: false,
    SVGPatternElement: false,
    SVGPoint: false,
    SVGPointList: false,
    SVGPolygonElement: false,
    SVGPolylineElement: false,
    SVGPreserveAspectRatio: false,
    SVGRadialGradientElement: false,
    SVGRect: false,
    SVGRectElement: false,
    SVGRenderingIntent: false,
    SVGSVGElement: false,
    SVGScriptElement: false,
    SVGSetElement: false,
    SVGStopElement: false,
    SVGStringList: false,
    SVGStylable: false,
    SVGStyleElement: false,
    SVGSwitchElement: false,
    SVGSymbolElement: false,
    SVGTRefElement: false,
    SVGTSpanElement: false,
    SVGTests: false,
    SVGTextContentElement: false,
    SVGTextElement: false,
    SVGTextPathElement: false,
    SVGTextPositioningElement: false,
    SVGTitleElement: false,
    SVGTransform: false,
    SVGTransformList: false,
    SVGTransformable: false,
    SVGURIReference: false,
    SVGUnitTypes: false,
    SVGUseElement: false,
    SVGVKernElement: false,
    SVGViewElement: false,
    SVGViewSpec: false,
    SVGZoomAndPan: false,
    TimeEvent: false,
    top: { writable: false, ignoreShadow: true },
    URL: false,
    WebSocket: false,
    window: false,
    Worker: false,
    XMLHttpRequest: false,
    XMLSerializer: false,
    XPathEvaluator: false,
    XPathException: false,
    XPathExpression: false,
    XPathNamespace: false,
    XPathNSResolver: false,
    XPathResult: false
};

// Extra browser reserved words

exports.devel = {
    alert: false,
    confirm: false,
    console: false,
    Debug: false,
    debugger: false,
    opera: false,
    prompt: false
};

// Widely adopted global names that are not part of ECMAScript standard

exports.nonstandard = {
    escape: false,
    unescape: false
};

// Globals provided by popular JavaScript environments.

exports.node = {
    __filename: false,
    __dirname: false,
    GLOBAL: false,
    global: false,
    root: false,
    module: false,
    require: false,

    // These globals are writeable because Node allows the following
    // usage pattern: var Buffer = require("buffer").Buffer;

    Buffer: true,
    console: true,
    exports: true,
    process: true,
    setTimeout: true,
    clearTimeout: true,
    setInterval: true,
    clearInterval: true,
    setImmediate: true,
    clearImmediate: true
};

// Cappuccino variables that should not be used as local variables

exports.cappuccino = {
    self: false,
    _cmd: false
};


text:
local MIXTURE = {}

MIXTURE.ID = 21;

MIXTURE.Results = "drug_beer_box_full";
MIXTURE.Ingredients = {'drug_beer_box_empty', 'drug_beer', 'drug_beer', 'drug_beer', 'drug_beer', 'drug_beer', 'drug_beer'};
MIXTURE.Requires = 	{

					};

MIXTURE.Free = true;

MIXTURE.RequiresHeatSource = false;
MIXTURE.RequiresWaterSource = false;
MIXTURE.RequiresSawHorse = false;

function MIXTURE.CanMix ( player, pos )
	return true;
end

GM:RegisterMixture(MIXTURE);

redpajama_set_name: RedPajamaGithub


text:
FROM yajo/centos-epel

MAINTAINER yajo@openaliasbox.org

# Launcher will patch configuration on first run and launch Odoo
CMD launch

# Odoo ports for web and chat
EXPOSE 8069 8072

# Variables used by the launch scripts
ENV ADMIN_PASSWORD=admin \
    ODOO_SERVER=odoo.py \
    UNACCENT=True \

# Variables used by the WDB debugger, in case you link a WDB container
    WDB_NO_BROWSER_AUTO_OPEN=True \
    WDB_SOCKET_SERVER=wdb \
    WDB_WEB_PORT=1984 \
    WDB_WEB_SERVER=localhost

# Install Odoo and psql (to install unaccent automatically)
RUN curl --output /etc/yum.repos.d/odoo.repo \
    http://nightly.odoo.com/8.0/nightly/rpm/odoo.repo && \
    yum -y install odoo postgresql && \

# Extra dependencies
# TODO Remove after fixing https://github.com/odoo/odoo/issues/4021
    yum -y install python-gevent && \

# Cannot use CentOS version of wkhtmltopdf because it's not patched to work
# without an X server, so let's install the official upstream RPM instead
    yum -y install http://download.gna.org/wkhtmltopdf/0.12/0.12.2.1/wkhtmltox-0.12.2.1_linux-centos7-amd64.rpm && \

# Add a debugger
    yum -y install gcc python-devel python-pip && \
    pip install wdb && \
    yum -y history undo last && \

# Add locales
    yum -y reinstall glibc-common && \

    yum clean all && \

# Create path for extra addons
    mkdir --parents /opt/odoo/extra-addons && \

# Create odoo $HOME to store some data
    mkdir /home/odoo && \
    chown odoo:odoo /home/odoo && \

# Configure launchers
    touch /firstrun
ADD debug launch pot unittest /usr/local/bin/
RUN chmod a+rx /usr/local/bin/*

# Folders modified at runtime by Odoo
VOLUME ["/home/odoo", "/var/lib/odoo", "/var/log/odoo"]


text:
/* MODIFICATIONS
 *
 * Modifications to this file are derived, directly or indirectly, from Original Code provided by the
 * Initial Developer and are Copyright 2010-2011 Google Inc.
 * See Changes.txt for a complete list of changes from the original source code.
 */

package sunlabs.brazil.server;

import sunlabs.brazil.properties.PropertiesList;
import sunlabs.brazil.util.http.HttpInputStream;
import sunlabs.brazil.util.http.HttpUtil;
import sunlabs.brazil.util.http.MimeHeaders;
import sunlabs.brazil.util.http.UnchunkingInputStream;

import java.io.ByteArrayOutputStream;
import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Dictionary;
import java.util.Hashtable;
import java.util.NoSuchElementException;
import java.util.StringTokenizer;

/**
 * Represents an HTTP transaction.   A new instance is created
 * by the server for each connection.
 *

 * Provides a set of accessor functions to fetch the individual fields
 * of the HTTP request.
 *

 * Utility methods that are generically useful for manipulating HTTP
 * requests are included here as well.  An instance of this class is
 * passed to handlers.  There will be exactly one request object per thead
 * at any time.
 *

 * The fields
 * {@link #headers},
 * {@link #query}, and
 * {@link #url}, and the method
 * {@link #getQueryData()}
 * are most often used to examine the content of the request.
 * The field
 * {@link #props}
 * contains information about the server, or up-stream handlers.
 *

 * The methods
 * {@link #sendResponse(String, String, int)} and
 * {@link Request#sendError(int, String)}
 * are commonly used to return content to the client.  The methods
 * {@link #addHeader(String)} and
 * {@link #setStatus(int)} can be used to modify the response headers
 * and return code respectively before the response is sent.
 *

 * Many of the other methods are used internally, but can be useful to
 * handlers that need finer control over the output that the above methods
 * provide.  Note that the order of the methods is important.  For instance,
 * the user cannot change the HTTP response headers (by calling the
 * addHeader method or by modifying the
 * responseHeaders field) after having already sent an HTTP
 * response.
 *

 * A number of the fields in the Request object are public,
 * by design.  Many of the methods are convenience methods; the underlying
 * data fields are meant to be accessed for more complicated operations,
 * such as changing the URL or deleting HTTP response headers.
 *
 * @see		Handler
 * @see		Server
 *
 * @author	Stephen Uhler (stephen.uhler@sun.com)
 * @author	Colin Stevens (colin.stevens@sun.com)
 * @version		2.18
 */
public class Request
{
  /**
   * Maximum number of blank lines allowed between requests before
   * aborting the connecion.  The spec allows 0, but some clients add
   * one or more.
   */
  //request.getProps().put("context_path", req.getContextPath());

  public static final int MAX_BLANKS = 10;
  /**
   * The server that initiated this request.  Only under rare circumstances
   * should this be modified.
   */
  public Server server;
  /**
   * Our connection to the client. Only under rare circumstances would this
   * need to be modified.
   */
  protected HttpInputStream in;

  /**
   * A set of properties local to this request.  The property is wrapped
   * in a PropertiesList object and initially is the head
   * of a linked list of properties that are searched in order.
   * This is useful for handlers that wish to communicate via properties
   * to down-stream handlers, such as modifying a server property for a
   * particular request.  Some handlers may even add entire new sets of
   * properties onto the front of request.props to temporarily
   * modify the properties seen by downstream handlers.
   */
  private PropertiesList props;

  /**
   * A PropertiesList object that wraps
   * server.props.  When this request is
   * created, a new PropertiesList, IOException wrapping
   * server.props is created and added to a list consisting
   * only of props and serverProps.
   */
  private PropertiesList serverProps;

  /**
   * The HTTP response to the client is written to this stream.  Normally
   * the convenience methods, such as sendResponse, are used
   * to send the response, but this field is available if a handler
   * needs to generate the response specially.
   *

   * If the user chooses to write the response directly to this stream, the
   * user is still encouraged to use the convenience methods, such as
   * sendHeaders, to first send the HTTP response headers.
   * The {@link sunlabs.brazil.filter.FilterHandler}
   * examines the HTTP response headers
   * set by the convenience methods to determine whether to filter the
   * output.
   *

   * Note that the HTTP response headers will not automatically be
   * sent as a side effect if the user writes to this stream.  The user
   * would either need to call the convenience method
   * sendHeaders or need to generate the HTTP response headers
   * themselves.
   *

   * This variable is declared as a Request.HttpOutputStream,
   * which provides the convenience method writeBytes to write
   * the byte representation of a string back to the client.  If the user
   * does not need this functionality, this variable may be accessed
   * simply as a normal OutputStream.
   *
   * @see	#sendResponse(String, String, int)
   * @see	#sendHeaders(int, String, int)
   */
  public HttpOutputStream out;

  /*
   * How many requests this Request will handle.  If this goes
   * to 0, then the connection will be closed even if
   * keepAlive is true.
   */
  protected int requestsLeft;

  //-----------------------------------------------------------------------

  /**
   * The HTTP request method, such as "GET", "POST", or "PUT".
   */
  private String method;

  /**
   * The URL specified in the request, not including any "?" query
   * string.
   *
NOTE: Traditionally handlers modify this as needed.  The request
   * property "url.orig" is set to match the url at creation time, and
   * should be considered "Read only", for those cases where the original
   * url is required.
   */
  private String url;

  /**
   * The query string specified after the URL, or "" if no
   * query string was specified.
   */
  private String query;

  /**
   * The HTTP protocol specified in the request, either "HTTP/1.0" or
   * "HTTP/1.1".
   *
   * @see	#version
   */
  private String protocolVersion;

  /**
   * Derived from {@link #protocolVersion}, the version of the HTTP protocol
   * used for this request.  Either 10 for "HTTP/1.0" or
   * 11 for "HTTP/1.1".
   */
  private int version;

  /**
   * The HTTP request headers.  Keys and values in this table correspond
   * the field names and values from each line in the HTTP header;
   * field names are case-insensitive, but the case of the values is
   * preserved.  The order of entries in this table corresponds to the
   * order in which the request headers were seen.  Multiple header lines
   * with the same key are stored as separate entries in the table.
   */
  private MimeHeaders headers;

  /**
   * The uploaded content of this request, usually from a POST.  Set to
   * null if the request has no content.
   */
  private byte[] postData;

  /**
   * true if the client requested a persistent connection,
   * false otherwise.  Derived from the {@link #protocolVersion} and
   * the {@link #headers},
   *

   * When "Keep-Alive" is requested, the client can issue multiple,
   * consecutive requests via a single socket connection.  By default:

   *
 HTTP/1.0 requests are not Keep-Alive, unless the
   * "Connection: Keep-Alive" header was present.
   *
 HTTP/1.1 requests are Keep-Alive, unless the "Connection: close"
   * header was present.
   *

   * The user can change this value from true to
   * false to forcefully close the connection to the client
   * after sending the response.  The user can change this value from
   * false to true if the client is using a
   * different header to request a persistent connection.  See
   * {@link #connectionHeader}.
   *

   * Regardless of this value, if an error is detected while receiving
   * or responding to an HTTP request, the connection will be closed.
   */
  private boolean keepAlive;

  /**
   * The header "Connection" usually controls whether the client
   * connection will be of type "Keep-Alive" or "close".  The same
   * header is written back to the client in the response headers.
   *

   * The field {@link #keepAlive} is set based on the value of the
   * "Connection" header.  However, not all clients use "Connection"
   * to request that the connection be kept alive.  For instance (although
   * it does not appear in the HTTP/1.0 or HTTP/1.1 documentation) both
   * Netscape and IE use the "Proxy-Connection" header when issuing
   * requests via an HTTP proxy.  If a Handler is written to
   * respond to HTTP proxy requests, it should set keepAlive
   * depending on the value of the "Proxy-Connection" header, and set
   * connectionHeader to "Proxy-Connection", since the
   * convenience methods like setResponse() use these fields
   * when constructing the response.  The server does not handle the
   * "Proxy-Connection" header by default, since trying to pre-anticipate
   * all the exceptions to the specification is a "slippery slope".
   */
  private String connectionHeader;

  /**
   * This is the server's protocol.  It is normally null, but
   * may be overriden to change the protocol on a per-request
   * basis.  If not set then server.protocol should be used instead.
   */

  private String serverProtocol;

  //-----------------------------------------------------------------------

  protected int statusCode;
  protected String statusPhrase;

  /**
   * The HTTP response headers.  Keys and values in this table correspond
   * to the HTTP headers that will be written back to the client when
   * the response is sent.  The order of entries in this table corresponds
   * to the order in which the HTTP headers will be sent.  Multiple header
   * lines with the same key will be stored as separate entries in the
   * table.
   *
   * @see	#addHeader(String, String)
   */
  private MimeHeaders responseHeaders;

  /*
   * True if the headers have already been sent, so that if sendError()
   * is called in the middle of sending a response, it won't send the
   * headers again, but will cause the connection to be closed afterwards.
   */
  protected boolean headersSent;

  /**
   * Time stamp for start of this request - set, but not used.
   */
  private long startMillis;

  /**
   *
   * If true, 0 length responses are turned into "204 no content".
   * Setting this violates the spec, but is expected behaviour in
   * many cases.
   */
  private static boolean noContentAs204 = false;

  /**
   * Size of the input/output buffers on the socket streams.
   * '0' uses the system default size.
   */
  public static int bufSize = 0;

  /**
   * Create a new http request.  Requests are created by the server for
   * use by handlers.
   *
   * @param	server
   *		The server that owns this request.
   *
   */
  public Request(Server server,InputStream in, OutputStream out) {
    this.server = server;
    this.in =  new HttpInputStream(in);
    if (out instanceof Request.HttpOutputStream) {
      this.out=(Request.HttpOutputStream) out;
    } else {
      this.out = new Request.HttpOutputStream(out);
    }

    requestsLeft = server.maxRequests;
    setKeepAlive(true);

    setHeaders(new MimeHeaders());
    setResponseHeaders(new MimeHeaders());
    setServerProtocol(null);
  }

  /**
   * Needed by VelocityFilter.Vrequest.  Should not be used to create
   * a Request object.
   */
  protected Request() {}

  /**
   * Returns a string representation of this Request.
   * The string representation is the first line (the method line) of the
   * HTTP request that this Request is handling.  Useful for
   * debugging.
   *
   * @return	The string representation of this Request.
   */
  @Override
  public String
  toString()
  {
    StringBuffer sb = new StringBuffer();

    sb.append(getMethod()).append(' ').append(getUrl());
    if ((getQuery() != null) && (getQuery().length() > 0)) {
      sb.append('?').append(getQuery());
    }
    sb.append(' ').append(getProtocol());
    return sb.toString();
  }

  /**
   * Reads an HTTP request from the socket.
   *
   * @return	true if the request was successfully read and
   *		parsed, false if the request was malformed.
   *
   * @throws	IOException
   *		if there was an IOException reading from the socket.  See
   *		the socket documentation for a description of socket
   *		exceptions.
   */
  public boolean
  getRequest()
  throws IOException
  {
    if (server.getProps().get("debugProps") != null) {
      if (getProps() != null) {
        getProps().dump(false, "at beginning of getRequest");
      }
    }

    /*
     * Reset state.
     */

    requestsLeft--;
    setConnectionHeader("Connection");

    setMethod(null);
    setUrl(null);
    setQuery(null);
    setProtocolVersion("HTTP/1.1");
    getHeaders().clear();
    setPostData(null);

    statusCode = 200;
    statusPhrase = "OK";
    getResponseHeaders().clear();
    setStartMillis(System.currentTimeMillis());
    out.bytesWritten=0;

    setServerProtocol(null);

    /*
     * Get first line of HTTP request (the method line).
     */

    String line = null;
    int count = 0;
    while (count++ < MAX_BLANKS) {
      line = in.readLine(MimeHeaders.MAX_LINE);
      if (line == null) {
        return false;
      } else if (line.length() > 0) {
        break;
      }
      log(Server.LOG_INFORMATIONAL, "Skipping blank line");
    }

    if (count >= MAX_BLANKS) {
      throw new IOException("Too many leading blanks in HTTP request");
    }

    log(Server.LOG_LOG, "Request " + requestsLeft + " " + line);

    try {
      StringTokenizer st = new StringTokenizer(line);
      setMethod(st.nextToken());
      setUrl(st.nextToken());
      setProtocolVersion(st.nextToken());
    } catch (NoSuchElementException e) {
      sendError(400, line, null);
      return false;
    }

    if (getProtocolVersion().equals("HTTP/1.0")) {
      setVersion(10);
    } else if (getProtocolVersion().equals("HTTP/1.1")) {
      setVersion(11);
    } else {
      sendError(505, line, null);
      return false;
    }

    /*
     * Separate query string from URL.
     */

    int index = getUrl().indexOf('?');
    if (index >= 0) {
      setQuery(getUrl().substring(index + 1));
      setUrl(getUrl().substring(0, index));
    } else {
      setQuery("");
    }

    getHeaders().read(in);

    /*
     * Remember POST data.  "Transfer-Encoding: chunked" is not handled
     * yet.
     */

    String str;

    str = getRequestHeader("Content-Length");
    if (str != null) {
      int len;
      try {
        len=Integer.parseInt(str);
        if (len > server.maxPost) {
          log(Server.LOG_DIAGNOSTIC, "Request", "too much post data");
          sendError(413, len + " bytes is too much data to post", null);
          return false;
        }
        setPostData(new byte[len]);
      } catch (Exception e) {
        sendError(411, str, null);
        return false;
      } catch (OutOfMemoryError e) {
        log(Server.LOG_DIAGNOSTIC, "Request", "out of memory for post data");
        sendError(413, str, null);
        return false;
      }
      log(Server.LOG_DIAGNOSTIC, "Request", "Reading content: " + str);
      in.readFully(getPostData());

      // dechunk input

    } else if ((str = getRequestHeader("Transfer-Encoding")) != null &&
        str.equals("chunked")) {
      ByteArrayOutputStream bout = new ByteArrayOutputStream();
      byte[] buf = new byte[4096];
      UnchunkingInputStream unchunk = new UnchunkingInputStream(in,
          getHeaders());
      int len;
      int total=0;
      while((len = unchunk.read(buf, 0, buf.length)) > 0) {
        bout.write(buf, 0, len);
        total += len;
        if (total > server.maxPost) {
          log(Server.LOG_DIAGNOSTIC, "Request", "too much post data");
          sendError(413, total + " bytes is too much data to post", null);
          return false;
        }
      }
      setPostData(bout.toByteArray());
    }

    str = getRequestHeader(getConnectionHeader());
    if ("Keep-Alive".equalsIgnoreCase(str)) {
      setKeepAlive(true);
    } else if ("close".equalsIgnoreCase(str)) {
      setKeepAlive(false);
    } else if (getVersion() > 10) {
      setKeepAlive(true);
    } else {
      setKeepAlive(false);
    }

    /*
     * Delay initialization until we know we need these things
     */
    setServerProps(new PropertiesList(server.getProps()));
    setProps(new PropertiesList());
    getProps().addBefore(getServerProps());

    /*
     * Keep track of the original url.  This is backwards (for
     * historical reasons
     */

    getProps().put("url.orig", getUrl());

    return true;
  }

  boolean
  shouldKeepAlive()
  {
    return (requestsLeft > 0) && isKeepAlive();
  }

  /**
   * The socket from which the HTTP request was received, and to where the
   * HTTP response will be written.  The user should not directly read from
   * or write to this socket.  The socket is provided other purposes, for
   * example, imagine a handler that provided different content depending
   * upon the IP address of the client.
   *
   * @return	The client socket that issued this HTTP request.
   */

  /**
   * Logs a message by calling Server.log.  Typically a
   * message is generated on the console or in a log file, if the
   * level is less than the current server log setting.
   *
   * @param	level
   *		The severity of the message.
   *
   * @param	message
   *		The message that will be logged.
   *
   * @see	Server#log(int, Object, String)
   */
  public void
  log(int level, String message)
  {
    log(level, null, message);
  }

  /**
   * Logs a message by calling Server.log.  Typically a
   * message is generated on the console or in a log file, if the
   * level is less than the current server log setting.
   *
   * @param	level
   *		The severity of the message.
   *
   * @param	obj
   *		The object that the message relates to.
   *
   * @param	message
   *		The message that will be logged.
   *
   * @see	Server#log(int, Object, String)
   */
  public void
  log(int level, Object obj, String message)
  {
    server.log(level, obj, message);
  }

  /*
   *-----------------------------------------------------------------------
   * Request methods.
   *-----------------------------------------------------------------------
   */

  /**
   * Returns the value that the given case-insensitive key maps to
   * in the HTTP request headers.  In order to do fancier things like
   * changing or deleting an existing request header, the user may directly
   * access the headers field.
   *
   * @param	key
   *		The key to look for in the HTTP request headers.  May not
   *		be null.
   *
   * @return	The value to which the given key is mapped, or
   *		null if the key is not in the headers.
   *
   * @see	#headers
   */
  public String
  getRequestHeader(String key)
  {
    return getHeaders().get(key);
  }

  /**
   * Retrieves the query data as a hashtable.
   * This includes both the query information included as part of the url
   * and any posted "application/x-www-form-urlencoded" data.
   *
   * @param   table
   *		An existing hashtable in which to put the query data as
   *		name/value pairs.  May be null, in which case
   *		a new hashtable is allocated.
   *
   * @return	The hashtable in which the query data was stored.
   */
  public Hashtable<String, String>
  getQueryData(Hashtable<String, String> table)
  {
    if (table == null) {
      table = new Hashtable<String, String>();
    }
    HttpUtil.extractQuery(getQuery(), table);
    if (getPostData() != null) {
      String contentType = getHeaders().get("Content-Type");
      if (contentType != null &&
          contentType.indexOf("www-form-urlencoded") != -1) {
        HttpUtil.extractQuery(new String(getPostData()), table);
      }
    }
    return table;
  }

  /**
   * Retrieves the query data as a hashtable.
   * This includes both the query information included as part of the url
   * and any posted "application/x-www-form-urlencoded" data.
   *
   * @return	The hashtable in which the query data was stored.
   */
  public Hashtable<String, String>
  getQueryData()
  {
    return getQueryData(null);
  }

  /*
   *-----------------------------------------------------------------------
   * Response methods.
   *-----------------------------------------------------------------------
   */

  /**
   * Sets the status code of the HTTP response.  The default status
   * code for a response is 200 if this method is not
   * called.
   *

   * An HTTP status phrase will be chosen based on the given
   * status code.  For example, the status code 404 will get
   * the status phrase "Not Found".
   *

   * If this method is called, it must be called before
   * sendHeaders is either directly or indirectly called.
   * Otherwise, it will have no effect.
   *
   * @param	code
   *		The HTTP status code, such as 200 or
   *		404.  If < 0, the HTTP status code will
   *		not be changed.
   *
   * @see	#sendHeaders(int, String, int)
   */
  public void
  setStatus(int code)
  {
    if (code >= 0) {
      setStatus(code, HttpUtil.getStatusPhrase(code));
    }
  }

  /**
   * Set the HTTP status code and status phrase of this request.  The given
   * status will be sent to the client when the user directly or indirectly
   * calls the method sendHeaders.  The given status phrase
   * replaces the default HTTP status phrase normally associated with the
   * given status code.
   *
   * @param	code
   *		The HTTP status code, such as 200 or
   *		404.
   *
   * @param	message
   *		The HTTP status phrase, such as "Okey dokey" or
   *		"I don't see it".
   *
   * @see	#sendHeaders(int, String, int)
   */
  protected void
  setStatus(int code, String message)
  {
    this.statusCode = code;
    this.statusPhrase = message;
  }

  /**
   * Return the status code.
   */

  public int getStatus() {
    return statusCode;
  }

  /**
   * Return uses of this socket
   */

  public int getReuseCount() {
    return server.maxRequests - requestsLeft;
  }

  /**
   * Adds a response header to the HTTP response.  In order to do fancier
   * things like appending a value to an existing response header, the
   * user may directly access the responseHeaders field.
   *

   * If this method is called, it must be called before
   * sendHeaders is either directly or indirectly called.
   * Otherwise, it will have no effect.
   *
   * @param	key
   *		The header name.
   *
   * @param	value
   *		The value for the request header.
   *
   * @see	#sendHeaders(int, String, int)
   * @see	#responseHeaders
   */
  public void
  addHeader(String key, String value)
  {
    getResponseHeaders().add(key, value);
  }

  /**
   * Adds a response header to the HTTP response.  In order to do fancier
   * things like appending a value to an existing response header, the
   * user may directly access the responseHeaders field.
   *

   * If this method is called, it must be called before
   * sendHeaders is either directly or indirectly called.
   * Otherwise, it will have no effect.
   *
   * @param	line
   *		The HTTP response header, of the form
   *		"key: value".
   *
   * @see	#sendHeaders(int, String, int)
   * @see	#responseHeaders
   */
  public void
  addHeader(String line)
  {
    int dots = line.indexOf(':');
    String key = line.substring(0, dots);
    String value = line.substring(dots + 1).trim();
    addHeader(key, value);
  }
  public void
  replaceHeader(String key, String value)
  {
    getResponseHeaders().put(key, value);
  }

  /**
   * Sends an HTTP response to the client.
   *

   * This method first calls sendHeaders to send the HTTP
   * response headers, then sends the given byte array as the HTTP
   * response body. If the request method is HEAD, or the result
   * code is "204", the body is not sent.
   *

   * The "Content-Length" will be set to the length of the given byte array.
   * The "Content-Type" will be set to the given MIME type.
   *
   * @param	body
   *		The array of bytes to send as the HTTP response body.  May
   *		not be null.
   *
   * @param	type
   *		The MIME type of the response, such as "text/html".  May be
   *		null to use the existing "Content-Type"
   *		response header (if any).
   *
   * @throws	IOException
   *		if there was an I/O error while sending the response to
   *		the client.
   *
   * @see	#sendHeaders(int, String, int)
   */
  public void
  sendResponse(byte[] body, String type)
  throws IOException
  {
    if (statusCode == 204) {
      sendHeaders(-1, type, 0);
    } else {
      sendHeaders(-1, type, body.length);
      if (!getMethod().equals("HEAD")) {
        out.write(body);
      }
    }
  }

  /**
   * Sends an HTTP response to the client.
   *

   * This method first calls sendHeaders to send the HTTP
   * response headers.  It then writes out the given string to the client
   * as a sequence of bytes.  Each character in the string is written out
   * by discarding its high eight bits.
   *

   * The "Content-Length" will be set to the length of the string.
   * The "Content-Type" will be set to the given MIME type.
   *

   * Note: to use a different character encoding, use
   * sendResponse(body.getBytes(encoding)...) instead.
   *
   * @param	body
   *		The string to send as the HTTP response body.  May
   *		not be null. If the request method is HEAD,
   *          the body is not sent.
   *
   * @param	type
   *		The MIME type of the response, such as "text/html".  May be
   *		null to preserve the existing "Content-Type"
   *		response header (if any).
   *
   * @param	code
   *		The HTTP status code for the response, such as
   *		200.  May be < 0 to preserve the existing
   *		status code.
   *
   * @throws	IOException
   *		if there was an I/O error while sending the response to
   *		the client.
   *
   * @see	#sendHeaders(int, String, int)
   */
  public void
  sendResponse(String body, String type, int code)
  throws IOException
  {
    if (statusCode == 204) {
      sendHeaders(-1, type, 0);
    } else {
      sendHeaders(code, type, body.length());
      if (!"HEAD".equals(getMethod())) {
        out.writeBytes(body);
      }
    }
  }

  /**
   * Convenience method that sends an HTTP response to the client
   * with a "Content-Type" of "text/html" and the default HTTP status
   * code.
   *
   * @param	body
   *		The string to send as the HTTP response body.
   *
   * @see	#sendResponse(String, String, int)
   */
  public void
  sendResponse(String body)
  throws IOException
  {
    sendResponse(body, "text/html", -1);
  }

  /**
   * Convenience method that sends an HTTP response to the client
   * with the default HTTP status code.
   *
   * @param	body
   *		The string to send as the HTTP response body.
   *		If the request method is HEAD,
   *          only the headers are sent to the client.
   *
   * @param	type
   *		The MIME type of the response.
   *
   * @see	#sendResponse(String, String, int)
   */
  public void
  sendResponse(String body, String type)
  throws IOException
  {
    sendResponse(body, type, -1);
  }

  /**
   * Sends the contents of the given input stream as the HTTP response.
   *

   * This method first calls sendHeaders to send the HTTP
   * response headers.  It then transfers a total of length
   * bytes of data from the given input stream to the client as the
   * HTTP response body.
   *

   * This method takes care of setting the "Content-Length" header
   * if the actual content length is known, or the "Transfer-Encoding"
   * header if the content length is not known (for HTTP/1.1 clients only).
   *

   * This method may set the keepAlive to false
   * before returning, if fewer than length bytes could be
   * read. If the request method is HEAD, only the headers are sent.
   *
   * @param	in
   *		The input stream to read from.
   *
   * @param	length
   *		The content length.  The number of bytes to send to the
   *		client.  May be < 0, in which case this method will read
   *		until reaching the end of the input stream.
   *
   * @param	type
   *		The MIME type of the response, such as "text/html".  May be
   *		null to preserve the existing "Content-Type"
   *		response header (if any).
   *
   * @param	code
   *		The HTTP status code for the response, such as
   *		200.  May be < 0 to preserve the existing
   *		status code.
   *
   * @throws	IOException
   *		if there was an I/O error while sending the response to
   *		the client.
   */
  public void
  sendResponse(InputStream in, int length, String type, int code)
  throws IOException
  {
    HttpInputStream hin = new HttpInputStream(in);

    byte[] buf = new byte[server.getBufsize()];

    if (length >= 0) {
      sendHeaders(code, type, length);
      if (!getMethod().equals("HEAD")) {
        if (hin.copyTo(out, length, buf) != length) {
          setKeepAlive(false);
        }
      }
    } else if (getVersion() <= 10) {
      setKeepAlive(false);
      sendHeaders(code, type, -1);
      if (!getMethod().equals("HEAD")) {
        hin.copyTo(out, -1, buf);
      }
    } else {
      if (getMethod().equals("HEAD")) {
        sendHeaders(code, type, -1);
        return;
      }

      /* Typically we won't know weather to chunk or not until
       * after we "send" the headers, so we set "chunked" encoding,
       * and let it be removed downstream (Yuk!)
       */

      addHeader("Transfer-Encoding", "chunked");
      sendHeaders(code, type, -1);

      if (out.canChunk()) {
        while (true) {
          int count = hin.read(buf);
          if (count < 0) {
            out.writeBytes("0\r\n\r\n");
            break;
          }
          out.writeBytes(Integer.toHexString(count) + "\r\n");
          out.write(buf, 0, count);
          out.writeBytes("\r\n");
        }
      } else {
        int count;
        while ((count = hin.read(buf)) >= 0) {
          out.write(buf, 0, count);
        }
      }
    }
  }

  /**
   * Sends a HTTP error response to the client.
   *
   * @param	code
   *		The HTTP status code.
   *
   * @param	clientMessage
   *		A short message to be included in the error response
   *		and logged to the server.
   */
  public void
  sendError(int code, String clientMessage)
  {
    sendError(code, clientMessage, null);
  }

  /**
   * Sends a HTTP error response to the client.
   *
   * @param	code
   *		The HTTP status code.
   *
   * @param	clientMessage
   *		A short message to be included in the error response.
   *
   * @param	logMessage
   *		A short message to be logged to the server.  This message is
   *		not sent to the client.
   */
  public void
  sendError(int code, String clientMessage, String logMessage)
  {
    setStatus(code);
    server.incrErrorCount();

    String message = clientMessage;
    if (message == null) {
      message = logMessage;
      logMessage = null;
    }
    log(Server.LOG_LOG, "Error",
        statusCode + " " + statusPhrase + ": " + message);
    if (logMessage != null) {
      log(Server.LOG_LOG, logMessage);
    }

    setKeepAlive(false);
    if (headersSent) {
      /*
       * The headers have already been sent.  We can't send an error
       * message in the middle of an existing response, so just close
       * this request.
       */

      return;
    }

    String body = "\n\n"
      + "<title>Error: " + statusCode + "</title>\n"
      + "\nGot the error: "
      + statusPhrase
      + "
\nwhile trying to obtain "
      + ((getUrl() == null) ? "unknown URL" : HttpUtil.htmlEncode(getUrl()))
      + "
\n"
      + HttpUtil.htmlEncode(clientMessage)
      + "\n\n";

    try {
      sendResponse(body, "text/html", statusCode);
    } catch (IOException e) {
      /*
       * Don't throw an error in the process of sending an error
       * message!
       */
    }
  }

  /**
   * Sends the HTTP status line and response headers to the client.  This
   * method is automatically invoked by sendResponse, but
   * can be manually invoked if the user needs direct access to the
   * client's output stream.  If this method is not called, then the
   * HTTP status and response headers will not automatically be sent to
   * the client; the user would be responsible for forming the entire
   * HTTP response.
   *

   * The user may call the addHeader method or modify the
   * responseHeaders field before calling this method.
   * This method then adds a number of HTTP headers, as follows:

   *
 "Date" - the current time, if this header is not already present.
   *
 "Server" - the server's name (from server.name), if
   *	    this header is not already present.
   *
 "Connection" - "Keep-Alive" or "close", depending upon the
   *	    keepAlive field.
   *
 "Content-Length" - set to the given length.
   *
 "Content-Type" - set to the given type.
   *

   *

   * The string used for "Connection" header actually comes from the
   * connectionHeader field.
   *
   * @param	code
   *		The HTTP status code for the response, such as
   *		200.  May be < 0 to preserve the existing
   *		status code.
   *
   * @param	type
   *		The MIME type of the response, such as "text/html".  May be
   *		null to preserve the existing "Content-Type"
   *		response header (if any).
   *
   * @param	length
   *		The length of the response body.  May be < 0 if the length
   *		is unknown and/or to preserve the existing "Content-Length"
   *		response header (if any).
   *
   * @throws	IOException
   *		if there was an I/O error while sending the headers to
   *		the client.
   *
   * @see	#setStatus(int)
   * @see	#addHeader(String, String)
   * @see	#sendResponse(String, String, int)
   * @see	#connectionHeader
   */
  public void
  sendHeaders(int code, String type, int length)
  throws IOException
  {
    setStatus(code);
    if (isNoContentAs204() && (length == 0) && (statusCode == 200)) {
      /*
       * No Content.
       */
      setStatus(204);
    }

    getResponseHeaders().putIfNotPresent("Date", HttpUtil.formatTime());
    if (server.getNameStr() != null) {
      getResponseHeaders().putIfNotPresent("Server", server.getNameStr());
    }
    String str = shouldKeepAlive() ? "Keep-Alive" : "close";
    getResponseHeaders().put(getConnectionHeader(), str);
    if (length >= 0) {
      getResponseHeaders().put("Content-Length", Integer.toString(length));
      getResponseHeaders().remove("Transfer-Encoding");
    }
    if (type != null) {
      getResponseHeaders().putIfNotPresent("Content-Type", type);
    }

    out.sendHeaders(this);
    // System.out.println("*** Sending headers: " +url+ " " + responseHeaders);
    headersSent = true;
  }

  /**
   * Send the response headers to the client.
   *  This consists of standard plus added headers.  The handler is reponsible
   *  for sending the reponse body.
   *
   * @param type	The document mime type
   * @param length	the document length
   *
   * @see Request#addHeader(String)
   * @see Request#sendResponse(String)
   * @see Request#setStatus(int)
   */

  /**
   * Responds to an HTTP request with a redirection reply, telling the
   * client that the requested url has moved.  Generally, this is used if
   * the client did not put a '/' on the end of a directory.
   *
   * @param	url
   *		The URL the client should have requested.  This URL may be
   *		fully-qualified (in the form "http://....") or host-relative
   *		(in the form "/...").
   *
   * @param	body
   *		The body of the redirect response, or null to
   *		send a hardcoded message.
   */
  public void
  redirect(String url, String body)
  throws IOException
  {
    if (url.startsWith("/")) {
      url = serverUrl() + url;
    }
    addHeader("Location", url);
    if (body == null) {
      body = "<title>Moved</title>
look for " + url + "
";
    }
    sendResponse(body, "text/html", 302);
  }

  /**
   * Returns the server's fully-qualified base URL.  This is "http://"
   * followed by the server's hostname and port.
   *

   * If the HTTP request header "Host" is present, it specifies the
   * hostname and port that will be used instead of the server's internal
   * name for itself.  Due bugs in certain browsers, when using the server's
   * internal name, the port number will be elided if it is 80.
   * (or 443 for https)..
   *
   * @return	The string representation of the server's URL.
   */
  public String
  serverUrl()
  {
    String host = getHeaders().get("Host");
    String protocol = getProtocol();
    int dfltPort =  protocol.equals("http") ? 80 : 443;
    if (host == null) {
      host = server.getHostName();
    }
    int index = host.lastIndexOf(":");
    if ((index < 0) && (server.getPort() != dfltPort)) {
      host += ":" + server.getPort();
    }
    return protocol + "://" + host;
  }

  /**
   * Return the protocol for this request.  Usually "http"
   */
  public String getProtocol()
  {
    return getServerProtocol()==null?server.getProtocol():getServerProtocol();
  }

  /**
   * The HttpOutputStream provides the convenience method
   * writeBytes for writing the byte representation of a
   * string, without bringing in the overhead and the deprecated warnings
   * associated with a java.io.DataOutputStream.
   *

   * The other methods in this class are here to allow the
   * FilterHandler and ChainSawHandler to
   * alter the behavior in an implementation specific way.  This behavior
   * is unfortunate, and might go away when a better strategy comes along.
   */
  public static class HttpOutputStream
  extends FilterOutputStream
  {
    /**
     * Count the number of bytes that are written to this stream
     */

    public int bytesWritten = 0;

    public
    HttpOutputStream(OutputStream out)
    {
      super(out);
    }

    public void
    writeBytes(String s)
    throws IOException
    {
      int len = s.length();
      for (int i = 0; i < len; i++) {
        this.out.write((byte) s.charAt(i));
      }
      bytesWritten += len;
    }

    public void write(byte b) throws IOException {
      this.out.write(b);
      bytesWritten++;
    }

    @Override
    public void
    write(byte[] buf, int off, int len) throws IOException {
      this.out.write(buf, off, len);
      bytesWritten += len;
    }

    public void
    sendHeaders(Request request)
    throws IOException
    {
      writeBytes(request.getProtocol() + " " + request.statusCode + " " +
          request.statusPhrase + "\r\n");
          request.getResponseHeaders().print(this.out);
          writeBytes("\r\n");
    }

    /**
     * By default, http/1.1 output streams support chunking.
     * If further output processing is required, then the chunking gets
     * in the way. Allow my subclasses to turn chunking off.  The
     * downstream processing functions need to insure valid http/1.1
     * in than case.
     */

    public boolean canChunk() {
      return true;
    }
  }

  /**
   * Adds the given Dictionary to the set of properties that
   * are searched by request.props.getProperty().  This method
   * is used to optimize the case when the caller has an existing
   * Dictionary object that should be added to the search
   * chain.
   *

   * Assume the caller is constructing a new Properties
   * object and wants to chain it onto the front of
   * request.props.  The following code is appropriate:
   *

   * /* Push a temporary Dictionary onto request.props. */
   * PropertiesList old = request.props;
   * (new PropertiesList()).addBefore(request.props);
   * request.props = request.props.getPrior();
   * request.props.put("foo", "bar");
   * request.props.put("baz", "garply");
   *
   * /* Do something that accesses new properties. */
   *     .
   *     .
   *     .
   *
   * /* Restore old Dictionary when done. */
   * request.props.remove();
   * request.props = old;
   *

   * However, addSharedProps may be called when the caller
   * has an existing set of Properties and is faced with
   * copying its contents into request.props and/or trying
   * to share the existing Properties object among multiple
   * threads concurrently.
   *

   * /* Some properties created at startup. */
   * static Properties P = new Properties();
   *     .
   *     .
   *     .
   * /* Share properties at runtime. */
   * request.addSharedProps(P);
   *
is more efficient and esthetically pleasing than:
   *

   * foreach key in P.keys() {
   *     request.props.put(key, P.get(key));
   * }
   *

   * The given Dictionary object is added to the
   * Properties.getProperty() search chain before serverProps;
   * it will be searched after the
   * request.props and before serverProps.
   * Multiple Dictionary objects can be added and they will
   * be searched in the order given.  The same Dictionary
   * object can be added multiple times safely.  However, the search
   * chain for the given Dictionary must not refer back to
   * request.props itself or a circular chain will be
   * created causing an infinite loop:
   *

   * request.addSharedProps(request.props);	            // Bad
   * request.addSharedProps(request.props.getWrapped());  // Good
   * Properties d1 = new Properties(request.props);
   * request.addSharedProps(d1);                          // Bad
   * Hashtable d2 = new Hashtable();
   * Properties d3 = new Properties();
   * request.addSharedProps(d2);		            // Good
   * request.addSharedProps(d3);		            // Good
   *

   * Subsequent calls to request.props.getProperty() may
   * fetch properties from an added Dictionary, but
   * request.put() will not modify those dictionaries.
   *
   * @param	d
   *		A Dictionary of String key/value
   *		pairs that will be added to the chain searched
   *		when request.props.getProperty() is called.  The
   *		dictionary d is "live", meaning that external
   *		changes to the contents of d will be seen on
   *		subsequent calls to request.props.getProperty().
   *
   * @return	false if the dictionary had already been added
   *		by a previous call to this method, true
   *		otherwise.
   */
  public boolean addSharedProps(Dictionary d) {
    return addSharedProps(d, null);
  }

  /**
   * Add a dictionary to the search list with an enumeration
   * prefix.  This reflects how the dictionary will be enumerated
   * with "glob" - enumeration will be skipped entirely if the
   * glob pattern doesn't start with the prefix.
   */
  public boolean
  addSharedProps(Dictionary d, String prefix)
  {
    boolean debug = server.getProps().get("debugProps") != null;
    if (getProps().wraps(d) != null) {
      if (debug) {
        System.out.println("addSharedProps didn't add dict"
            + Integer.toHexString(System.identityHashCode(d)));
      }
      return false;
    }
    PropertiesList pl = new PropertiesList(d);
    pl.addAfter(getProps());
    if (debug) {
      getProps().dump(true, "at addSharedProps");
    }
    pl.setPrefix(prefix);
    return true;
  }

  /**
   * Add a dictionary with the specified enumeration prefix
   */

  /**
   * Removes a Dictionary added by
   * addSharedProps.  Dictionary objects may
   * be removed in any order.  Dictionary objects do not need
   * to be removed; they will automatically get cleaned up at the end of
   * the request.
   *
   * @param	d
   *		The Dictionary object to remove from the
   *		request.props.getProperty() search chain.
   *
   * @return	true if the Dictionary was found
   *		and removed, false if the Dictionary
   *		was not found (it had already been removed or had never been
   *		added).
   */
  public boolean
  removeSharedProps(Dictionary d)
  {
    PropertiesList pl = getProps().wraps(d);
    if (pl != null && pl != getProps() && pl != getServerProps()) {
      pl.remove();
      if (server.getProps().get("debugProps") != null) {
        pl.dump(true, "at removeSharedProps");
      }
      return true;
    }
    return false;
  }

  public void setProps(PropertiesList props) {
    this.props = props;
  }

  public PropertiesList getProps() {
    return props;
  }

  public void setServerProps(PropertiesList serverProps) {
    this.serverProps = serverProps;
  }

  public PropertiesList getServerProps() {
    return serverProps;
  }

  public void setMethod(String method) {
    this.method = method;
  }

  public String getMethod() {
    return method;
  }

  public void setUrl(String url) {
    this.url = url;
  }

  public String getUrl() {
    return url;
  }

  public void setQuery(String query) {
    this.query = query;
  }

  public String getQuery() {
    return query;
  }

  public void setProtocolVersion(String protocol) {
    this.protocolVersion = protocol;
  }

  public String getProtocolVersion() {
    return protocolVersion;
  }

  public void setVersion(int version) {
    this.version = version;
  }

  public int getVersion() {
    return version;
  }

  public void setHeaders(MimeHeaders headers) {
    this.headers = headers;
  }

  public MimeHeaders getHeaders() {
    return headers;
  }

  public void setPostData(byte[] postData) {
    this.postData = postData;
  }

  public byte[] getPostData() {
    return postData;
  }

  public void setKeepAlive(boolean keepAlive) {
    this.keepAlive = keepAlive;
  }

  public boolean isKeepAlive() {
    return keepAlive;
  }

  /**
   * @param connectionHeader the connectionHeader to set
   */
   public void setConnectionHeader(String connectionHeader) {
     this.connectionHeader = connectionHeader;
   }

   /**
    * @return the connectionHeader
    */
   public String getConnectionHeader() {
     return connectionHeader;
   }

   /**
    * @param serverProtocol the serverProtocol to set
    */
   public void setServerProtocol(String serverProtocol) {
     this.serverProtocol = serverProtocol;
   }

   /**
    * @return the serverProtocol
    */
   public String getServerProtocol() {
     return serverProtocol;
   }

   /**
    * @param responseHeaders the responseHeaders to set
    */
   public void setResponseHeaders(MimeHeaders responseHeaders) {
     this.responseHeaders = responseHeaders;
   }

   /**
    * @return the responseHeaders
    */
   public MimeHeaders getResponseHeaders() {
     return responseHeaders;
   }

   /**
    * @param startMillis the startMillis to set
    */
   public void setStartMillis(long startMillis) {
     this.startMillis = startMillis;
   }

   /**
    * @return the startMillis
    */
   public long getStartMillis() {
     return startMillis;
   }

   /**
    * @param noContentAs204 the noContentAs204 to set
    */
   public static void setNoContentAs204(boolean noContentAs204) {
     Request.noContentAs204 = noContentAs204;
   }

   /**
    * @return the noContentAs204
    */
   public static boolean isNoContentAs204() {
     return noContentAs204;
   }
}


text:
<?php declare(strict_types=1);

namespace Novuso\Common\Adapter\Console\Symfony;

use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;

class OutputStyle extends SymfonyStyle
{
    /**
     * Console output
     *
     * @var OutputInterface
     */
    protected $output;

    /**
     * Constructs OutputStyle
     *
     * @param InputInterface  $input  The input
     * @param OutputInterface $output The output
     */
    public function __construct(InputInterface $input, OutputInterface $output)
    {
        $this->output = $output;
        parent::__construct($input, $output);
    }

    /**
     * Checks if verbosity is quiet (-q)
     *
     * @return bool
     */
    public function isQuiet(): bool
    {
        return $this->output->getVerbosity() === OutputInterface::VERBOSITY_QUIET;
    }

    /**
     * Checks if verbosity is verbose (-v)
     *
     * @return bool
     */
    public function isVerbose(): bool
    {
        return $this->output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE;
    }

    /**
     * Checks if verbosity is very verbose (-vv)
     *
     * @return bool
     */
    public function isVeryVerbose(): bool
    {
        return $this->output->getVerbosity() >= OutputInterface::VERBOSITY_VERY_VERBOSE;
    }

    /**
     * Checks if verbosity is debug (-vvv)
     *
     * @return bool
     */
    public function isDebug(): bool
    {
        return $this->output->getVerbosity() >= OutputInterface::VERBOSITY_DEBUG;
    }
}


text:
var gulp = require('gulp'),
	concat = require('gulp-concat'),
	mocha = require('gulp-mocha'),
	rename = require('gulp-rename'),
	babel = require('gulp-babel');

var scriptSrc = './source/',
	scriptDst = '.',
	scriptFile = 'statistics.js',
	scriptFileMin = 'statistics.min.js',

	testsSrc = './tests/',

	docDst = './docs/',
	docSrc = docDst + 'source/',
	buildDocs = require(docSrc + 'buildDocs.js'),
	buildDocsMF = require(docSrc + 'buildDocsMultiFile.js'),

	srcList = [
		scriptSrc + 'core.js',
		scriptSrc + 'centralTendency.js',
		scriptSrc + 'dispersion.js',
		scriptSrc + 'shape.js',
		scriptSrc + 'algebra.js',
		scriptSrc + 'correlation.js',
		scriptSrc + 'regression.js',
		scriptSrc + 'distributions.js',
		scriptSrc + 'tests_nonparametric.js',
		scriptSrc + 'tests_parametric.js',
		scriptSrc + 'error.js',
		scriptSrc + 'random.js'
	];

/***
	Build documentation
 ***/

gulp.task('buildDocs', function() {
	buildDocs('index.html')
		.pipe(gulp.dest(docDst));
});

gulp.task('buildDocsMultiFile', function() {
	buildDocsMF('index.html', docDst)
		.pipe(gulp.dest(docDst));
});

gulp.task('buildReadmeMD', function() {
	buildDocsMF('README.MD', scriptDst, true)
		.pipe(gulp.dest(scriptDst));
});

/***
	Perform unit tests
 ***/

gulp.task('test', function() {
	return  gulp.src(testsSrc + '*.js')
				.pipe(mocha());
});

/***
	Build library
 ***/

gulp.task('build', ['buildDocsMultiFile', 'buildReadmeMD'], function() {
	return  gulp.src(srcList)
				.pipe(concat(scriptFile))
				.pipe(gulp.dest(scriptDst))
				.pipe(rename(scriptFileMin))
				.pipe(babel({presets: ['babili']}))
				.pipe(gulp.dest(scriptDst));
});


text:
package net.community.chest.net.proto.text.imap4;

public class IncrementalIMAP4TagsGenerator implements IMAP4TagsGenerator {
    /**
     * Last returned value - next one will be +1 (wrapped around if negative)
     */
    private int    _curTag /* =0 */;
    /**
     * Initialized constructor
     * @param startTag value to start from - if negative then its
     * <U>absolute</U> value will be used
     */
    public IncrementalIMAP4TagsGenerator (int startTag)
    {
        // need to do this because Math.abs(Integer.MIN_VALUE) => Integer.MIN_VALUE
        if ((_curTag=Math.abs(startTag)) < 0)
            _curTag = 0;
    }
    /**
     * Default constructor - starts from {@link System#currentTimeMillis()}
     */
    public IncrementalIMAP4TagsGenerator ()
    {
        this((int) System.currentTimeMillis());
    }
    /* NOTE !!! not synchronized
     * @see net.community.chest.net.proto.text.imap4.IMAP4TagsGenerator#getNextTag()
     */
    @Override
    public int getNextTag ()
    {
        _curTag++;

        if (_curTag < 0)
            _curTag = 0;

        return _curTag;
    }
}


text:
{% block modal_irods_login %}

                <form class="form-signin" role="form" action="/irods_login/" method="post" id="irodsLogin">

                        <button type="button" class="close" data-dismiss="modal">×Close</button>

Log in to an iRODS Server

                        {% csrf_token %}
                        <input type="hidden" name="path" value="{{ request.path }}"/>

                            iRODS Username:
                            <input id="username" class="form-control" name="username" placeholder="Username" value="{{ user.username }}" type="text" />

                            iRODS Password:
                            <input id="password" class="form-control" name="password" placeholder="Password" value="" type="password" />

                            Host:
                            <input id="host" class="form-control" name="host" placeholder="Host" value="users.hydroshare.org" type="text" />

                            Port:
                            <input id="port" class="form-control" name="port" placeholder="port" value="1247" type="text" />

                            Zone:
                            <input id="zone" class="form-control" name="zone" placeholder="Zone" value="hydroshareuserZone" type="text" />

                        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                        <button type="submit" class="btn btn-primary">Sign in</button>

                </form>

{% endblock %}

{% block extra_js %}

{% endblock %}


text:
.jp-carousel .jp-carousel-slide {
	display: none !important;
}
.jp-carousel {
	text-align: center!important;
	width:100%!important;
}
.jp-carousel .selected {
	margin: 0 auto;
	display: block !important;
	width: auto;
	position: relative!important;
}


text:
/* $OpenLDAP: pkg/ldap/servers/slapd/back-perl/perl_back.h,v 1.15.2.6 2011/01/04 23:50:42 kurt Exp $ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
 *
 * Copyright 1999-2011 The OpenLDAP Foundation.
 * Portions Copyright 1999 John C. Quillan.
 * Portions Copyright 2002 myinternet Limited.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted only as authorized by the OpenLDAP
 * Public License.
 *
 * A copy of this license is available in file LICENSE in the
 * top-level directory of the distribution or, alternatively, at
 * <http://www.OpenLDAP.org/license.html>.
 */

#ifndef PERL_BACK_H
#define PERL_BACK_H 1

#include <EXTERN.h>
#include <perl.h>
#undef _	/* #defined by both Perl and ac/localize.h */
#include "asperl_undefs.h"

#include "portable.h"

#include "slap.h"

LDAP_BEGIN_DECL

/*
 * From Apache mod_perl: test for Perl version.
 */

#if defined(pTHX_) || (PERL_REVISION > 5 || (PERL_REVISION == 5 && PERL_VERSION >= 6))
#define PERL_IS_5_6
#endif

#define EVAL_BUF_SIZE 500

extern ldap_pvt_thread_mutex_t  perl_interpreter_mutex;

#ifdef PERL_IS_5_6
/* We should be using the PL_errgv, I think */
/* All the old style variables are prefixed with PL_ now */
# define errgv	PL_errgv
# define na	PL_na
#endif

#if defined( HAVE_WIN32_ASPERL ) || defined( USE_ITHREADS )
/* pTHX is needed often now */
# define PERL_INTERPRETER			my_perl
# define PERL_BACK_XS_INIT_PARAMS		pTHX
# define PERL_BACK_BOOT_DYNALOADER_PARAMS	pTHX, CV *cv
#else
# define PERL_INTERPRETER			perl_interpreter
# define PERL_BACK_XS_INIT_PARAMS		void
# define PERL_BACK_BOOT_DYNALOADER_PARAMS	CV *cv
#endif

extern PerlInterpreter *PERL_INTERPRETER;

typedef struct perl_backend_instance {
	char	*pb_module_name;
	SV	*pb_obj_ref;
	int	pb_filter_search_results;
} PerlBackend;

LDAP_END_DECL

#include "proto-perl.h"

#endif /* PERL_BACK_H */


text:
$(document).ready(function() {
	$('.letter').each(function() {
		// grab our trueletter container
		var trueletter = $(this).find('.trueletter');

		// clone trueletter container and do some CSS/Class stuff to it
		$(trueletter).css('display','none').clone().insertAfter(trueletter).removeClass('trueletter').addClass('randomletter').css('display','block');

		// set all other vars we'll use
		var randomletter = $(this).find('.randomletter');
		var counter = 0;
		var interval = 0;
		var interval = Math.floor(Math.random()*(200-100+1)+100); // max 150 and min 100

		// interval function to run through our loop
		// randomizes our letter before hiding it and showing our true letter
		var randomize = setInterval(function() {
			//randomize the letter
			var rand = String.fromCharCode((Math.random() * 50) + 43);
			$(randomletter).text(rand);

			// stop loop with conditional
			if( counter >= interval ) {
				clearInterval(randomize);
				randomize = 0;
				$(randomletter).css('display','none');
				$(trueletter).css('display','block');
			};
			counter++;
		}, 10);
	});
});


text:
<?php

// make the DSN
$dsn = 'mysql:host=localhost;dbname=world;';
$user = 'user';
$password = 'secret';

// try to make the connection to the database
try
{
  $dbh = new PDO($dsn, $user, $password);
  $dbh->setAttribute(PDO::ATTR_ERRMODE,
      PDO::ERRMODE_EXCEPTION);
  $sql = 'CALL getQuote()';
  $stmt = $dbh->prepare($sql);
  $stmt->execute();
  $return_string = $stmt->fetch();
}
catch (PDOException $e)
{
  echo 'PDO Exception Caught.  ';
  echo 'Error with the database: <br />';
  echo 'SQL Query: ', $sql;
  echo 'Error: ' . $e->getMessage();
}

echo 'Called stored procedure.  It returned: ', $return_string[0];

?>