httpd.js File Reference

Go to the source code of this file.

Functions

function NS_ASSERT (cond, msg)
 
function HttpError (code, description)
 
function array2obj (arr)
 
function range (x, y)
 
function dumpn (str)
 
function dumpStack ()
 
function getRootPrefBranch ()
 
function toDateString (date)
 
function printObj (o, showMembers)
 
function nsHttpServer ()
 
function ServerIdentity ()
 
function Connection (input, output, server, port, outgoingPort, number)
 
function readBytes (inputStream, count)
 
function RequestReader (connection)
 
function findCRLF (array)
 
function LineData ()
 
function createHandlerFunc (handler)
 
function defaultIndexHandler (metadata, response)
 
function fileSort (a, b)
 
function toInternalPath (path, encoded)
 
function maybeAddHeaders (file, metadata, response)
 
function ServerHandler (server)
 
function FileMap ()
 
function isCTL (code)
 
function Response (connection)
 
function notImplemented ()
 
function WriteThroughCopier (input, output, observer, context)
 
function htmlEscape (str)
 
function nsHttpVersion (versionString)
 
function nsHttpHeaders ()
 
function nsSimpleEnumerator (items)
 
function Request (port)
 
function makeFactory (ctor)
 
function NSGetModule (compMgr, fileSpec)
 
function server (port, basePath)
 

Variables

const Cc = Components.classes
 
const Ci = Components.interfaces
 
const Cr = Components.results
 
const Cu = Components.utils
 
const CC = Components.Constructor
 
const PR_UINT32_MAX = Math.pow(2, 32) - 1
 
const EXPORTED_SYMBOLS = ["server", "nsHttpServer", "HttpError"]
 
var DEBUG = false
 
var gGlobalObject = this
 
HttpError prototype
 
const HTTP_400 = new HttpError(400, "Bad Request")
 
const HTTP_401 = new HttpError(401, "Unauthorized")
 
const HTTP_402 = new HttpError(402, "Payment Required")
 
const HTTP_403 = new HttpError(403, "Forbidden")
 
const HTTP_404 = new HttpError(404, "Not Found")
 
const HTTP_405 = new HttpError(405, "Method Not Allowed")
 
const HTTP_406 = new HttpError(406, "Not Acceptable")
 
const HTTP_407 = new HttpError(407, "Proxy Authentication Required")
 
const HTTP_408 = new HttpError(408, "Request Timeout")
 
const HTTP_409 = new HttpError(409, "Conflict")
 
const HTTP_410 = new HttpError(410, "Gone")
 
const HTTP_411 = new HttpError(411, "Length Required")
 
const HTTP_412 = new HttpError(412, "Precondition Failed")
 
const HTTP_413 = new HttpError(413, "Request Entity Too Large")
 
const HTTP_414 = new HttpError(414, "Request-URI Too Long")
 
const HTTP_415 = new HttpError(415, "Unsupported Media Type")
 
const HTTP_416 = new HttpError(416, "Requested Range Not Satisfiable")
 
const HTTP_417 = new HttpError(417, "Expectation Failed")
 
const HTTP_500 = new HttpError(500, "Internal Server Error")
 
const HTTP_501 = new HttpError(501, "Not Implemented")
 
const HTTP_502 = new HttpError(502, "Bad Gateway")
 
const HTTP_503 = new HttpError(503, "Service Unavailable")
 
const HTTP_504 = new HttpError(504, "Gateway Timeout")
 
const HTTP_505 = new HttpError(505, "HTTP Version Not Supported")
 
const HTTP_ERROR_CODES = array2obj(range(400, 417).concat(range(500, 505)))
 
const HIDDEN_CHAR = "^"
 
const HEADERS_SUFFIX = HIDDEN_CHAR + "headers" + HIDDEN_CHAR
 
const SJS_TYPE = "sjs"
 
var gThreadManager = null
 
var gRootPrefBranch = null
 
const ServerSocket
 
const BinaryInputStream
 
const BinaryOutputStream
 
const ScriptableInputStream
 
const Pipe
 
const FileInputStream
 
const ConverterInputStream
 
const WritablePropertyBag
 
const SupportsString
 
const HOST_REGEX
 
const READER_IN_REQUEST_LINE = 0
 
const READER_IN_HEADERS = 1
 
const READER_IN_BODY = 2
 
const READER_FINISHED = 3
 
const CR = 0x0D
 
const LF = 0x0A
 
const IS_TOKEN_ARRAY
 
Response SEGMENT_SIZE = 8192
 
const headerUtils
 
nsHttpVersion HTTP_1_0 = new nsHttpVersion("1.0")
 
nsHttpVersion HTTP_1_1 = new nsHttpVersion("1.1")
 
const module
 

Function Documentation

function array2obj (   arr)

Creates a hash with fields corresponding to the values in arr.

Definition at line 129 of file httpd.js.

function Connection (   input,
  output,
  server,
  port,
  outgoingPort,
  number 
)

Represents a connection to the server (and possibly in the future the thread on which the connection is processed).

Parameters
input: nsIInputStream stream from which incoming data on the connection is read
output: nsIOutputStream stream to write data out the connection
server: nsHttpServer the server handling the connection
port: int the port on which the server is running
outgoingPort: int the outgoing port used by this connection
number: uint a serial number used to uniquely identify this connection

Stream of incoming data.

Stream for outgoing data.

The server associated with this request.

The port on which the server is running.

The outgoing poort used by this connection.

The serial number of this connection.

The request for which a response is being generated, null if the incoming request has not been fully received or if it had errors.

State variables for debugging.

Definition at line 1049 of file httpd.js.

Here is the call graph for this function:

function createHandlerFunc (   handler)

Creates a request-handling function for an nsIHttpRequestHandler object.

Definition at line 1879 of file httpd.js.

function defaultIndexHandler (   metadata,
  response 
)

The default handler for directories; writes an HTML response containing a slightly-formatted directory listing.

Definition at line 1889 of file httpd.js.

Here is the call graph for this function:

Here is the caller graph for this function:

function dumpn (   str)

dump(str) with a trailing "\n" – only outputs if DEBUG

Definition at line 172 of file httpd.js.

Here is the caller graph for this function:

function dumpStack ( )

Dumps the current JS stack if DEBUG.

Definition at line 179 of file httpd.js.

Here is the call graph for this function:

function FileMap ( )

Maps absolute paths to files on the local file system (as nsILocalFiles).

Hash which will map paths to nsILocalFiles.

Definition at line 3239 of file httpd.js.

Here is the caller graph for this function:

function fileSort (   a,
  b 
)

Sorts a and b (nsIFile objects) into an aesthetically pleasing order.

Definition at line 1957 of file httpd.js.

Here is the caller graph for this function:

function findCRLF (   array)

Calculates the number of characters before the first CRLF pair in array, or -1 if the array contains no CRLF pair.

Parameters
array: Array an array of numbers in the range [0, 256), each representing a single character; the first CRLF is the lowest index i where |array[i] == "\r".charCodeAt(0)| and |array[i+1] == "\n".charCodeAt(0)|, if such an |i| exists, and -1 otherwise
Returns
int the index of the first CRLF if any were present, -1 otherwise

Definition at line 1794 of file httpd.js.

function getRootPrefBranch ( )

Definition at line 192 of file httpd.js.

function htmlEscape (   str)

Converts the given string into a string which is safe for use in an HTML context.

Parameters
str: string the string to make HTML-safe
Returns
string an HTML-safe version of str

Definition at line 4204 of file httpd.js.

Here is the caller graph for this function:

function HttpError (   code,
  description 
)

Constructs an HTTP error object.

Definition at line 86 of file httpd.js.

function isCTL (   code)

Determines whether the given character code is a CTL.

Parameters
code: uint the character code
Returns
boolean true if code is a CTL, false otherwise

Definition at line 3321 of file httpd.js.

function LineData ( )

A container which provides line-by-line access to the arrays of bytes with which it is seeded.

An array of queued bytes from which to get line-based characters.

Definition at line 1809 of file httpd.js.

Here is the caller graph for this function:

function makeFactory (   ctor)

Creates a factory for instances of an object created using the passed-in constructor.

Definition at line 4636 of file httpd.js.

function maybeAddHeaders (   file,
  metadata,
  response 
)

Adds custom-specified headers for the given file to the given response, if any such headers are specified.

Parameters
filethe file on the disk which is to be written
metadatametadata about the incoming request
responsethe Response to which any specified headers/data should be written
Exceptions
HTTP_500if an error occurred while processing custom-specified headers

Definition at line 2012 of file httpd.js.

Here is the call graph for this function:

function notImplemented ( )

Serves double duty in WriteThroughCopier implementation.

Definition at line 3930 of file httpd.js.

function NS_ASSERT (   cond,
  msg 
)

Asserts that the given condition holds. If it doesn't, the given message is dumped, a stack trace is printed, and an exception is thrown to attempt to stop execution (which unfortunately must rely upon the exception not being accidentally swallowed by the code that uses it).

Definition at line 70 of file httpd.js.

Here is the call graph for this function:

Here is the caller graph for this function:

function NSGetModule (   compMgr,
  fileSpec 
)

NSGetModule, so this code can be used as a JS component.

Definition at line 4725 of file httpd.js.

function nsHttpHeaders ( )

An object which stores HTTP headers for a request or response.

Note that since headers are case-insensitive, this object converts headers to lowercase before storing them. This allows the getHeader and hasHeader methods to work correctly for any case of a header, but it means that the values returned by .enumerator may not be equal case-sensitively to the values passed to setHeader when adding headers to this.

A hash of headers, with header field names as the keys and header field values as the values. Header field names are case-insensitive, but upon insertion here they are converted to lowercase. Header field values are normalized upon insertion to contain no leading or trailing whitespace.

Note also that per RFC 2616, section 4.2, two headers with the same name in a message may be treated as one header with the same field name and a field value consisting of the separate field values joined together with a "," in their original order. This hash stores multiple headers with the same name in this manner.

Definition at line 4285 of file httpd.js.

Here is the caller graph for this function:

function nsHttpServer ( )

Instantiates a new HTTP server.

The port on which this server listens.

The socket associated with this.

The handler used to process requests to this server.

Naming information for this server.

Indicates when the server is to be shut down at the end of the request.

True if the socket in this is closed (and closure notifications have been sent and processed if the socket was ever opened), false otherwise.

Used for tracking existing connections and ensuring that all connections are properly cleaned up before server shutdown; increases by 1 for every new incoming connection.

Hash of all open connections, indexed by connection number at time of creation.

Definition at line 339 of file httpd.js.

Here is the call graph for this function:

Here is the caller graph for this function:

function nsHttpVersion (   versionString)

Constructs an object representing an HTTP version (see section 3.1).

Parameters
versionStringa string of the form "#.#", where # is an non-negative decimal integer with or without leading zeros
Exceptions
ifversionString does not specify a valid HTTP version number

The major version number of this, as a number.

The minor version number of this, as a number.

Definition at line 4223 of file httpd.js.

Here is the call graph for this function:

Here is the caller graph for this function:

function nsSimpleEnumerator (   items)

Constructs an nsISimpleEnumerator for the given array of items.

Parameters
items: Array the items, which must all implement nsISupports

Definition at line 4432 of file httpd.js.

function printObj (   o,
  showMembers 
)

Prints out a human-readable representation of the object o and its fields, omitting those whose names begin with "_" if showMembers != true (to ignore "private" properties exposed via getters/setters).

Definition at line 321 of file httpd.js.

Here is the call graph for this function:

function range (   x,
  y 
)

Returns an array of the integers x through y, inclusive.

Definition at line 138 of file httpd.js.

Here is the caller graph for this function:

function readBytes (   inputStream,
  count 
)

Returns an array of count bytes from the given input stream.

Definition at line 1148 of file httpd.js.

function Request (   port)

A representation of the data in an HTTP request.

Parameters
port: uint the port on which the server receiving this request runs

Method of this request, e.g. GET or POST.

Path of the requested resource; empty paths are converted to '/'.

Query string, if any, associated with this request (not including '?').

Scheme of requested resource, usually http, always lowercase.

Hostname on which the requested resource resides.

Port number over which the request was received.

Stream from which data in this request's body may be read.

Stream to which data in this request's body is written.

The headers in this request.

For the addition of ad-hoc properties and new functionality without having to change nsIHttpRequestMetadata every time; currently lazily created, as its only use is in directory listings.

Definition at line 4467 of file httpd.js.

Here is the call graph for this function:

Here is the caller graph for this function:

function RequestReader (   connection)

Reads incoming request data asynchronously, does any necessary preprocessing, and forwards it to the request handler. Processing occurs in three states:

READER_IN_REQUEST_LINE Reading the request's status line READER_IN_HEADERS Reading headers in the request READER_IN_BODY Reading the body of the request READER_FINISHED Entire request has been read and processed

During the first two stages, initial metadata about the request is gathered into a Request object. Once the status line and headers have been processed, we start processing the body of the request into the Request. Finally, when the entire body has been read, we create a Response and hand it off to the ServerHandler to be given to the appropriate request handler.

Parameters
connection: Connection the connection for the request being read

Connection metadata for this request.

A container providing line-by-line access to the raw bytes that make up the data which has been read from the connection but has not yet been acted upon (by passing it to the request handler or by extracting request metadata from it).

The amount of data remaining to be read from the body of this request. After all headers in the request have been read this is the value in the Content-Length header, but as the body is read its value decreases to zero.

The current state of parsing the incoming request.

Metadata constructed from the incoming request for the request handler.

Used to preserve state if we run out of line data midway through a multi-line header. _lastHeaderName stores the name of the header, while _lastHeaderValue stores the value we've seen so far for the header.

These fields are always either both undefined or both strings.

Definition at line 1180 of file httpd.js.

Here is the call graph for this function:

function Response (   connection)

Represents a response to an HTTP request, encapsulating all details of that response. This includes all headers, the HTTP version, status code and explanation, and the entity itself.

Parameters
connection: Connection the connection over which this response is to be written

The connection over which this response will be written.

The HTTP version of this response; defaults to 1.1 if not set by the handler.

The HTTP code of this response; defaults to 200.

The description of the HTTP code in this response; defaults to "OK".

An nsIHttpHeaders object in which the headers in this response should be stored. This property is null after the status line and headers have been written to the network, and it may be modified up until it is cleared, except if this._finished is set first (in which case headers are written asynchronously in response to a finish() call not preceded by flushHeaders()).

Set to true when this response is ended (completely constructed if possible and the connection closed); further actions on this will then fail.

A stream used to hold data written to the body of this response.

A stream containing all data that has been written to the body of this response so far. (Async handlers make the data contained in this unreliable as a way of determining content length in general, but auxiliary saved information can sometimes be used to guarantee reliability.)

The stream copier which copies data written to the body by a request handler to the network.

True if this response has been designated as being processed asynchronously rather than for the duration of a single call to nsIHttpRequestHandler.handle.

True iff finish() has been called on this, signaling that no more changes to this may be made.

True iff powerSeized() has been called on this, signaling that this response is to be handled manually by the response handler (which may then send arbitrary data in response, even non-HTTP responses).

Definition at line 3334 of file httpd.js.

Here is the call graph for this function:

function server (   port,
  basePath 
)

Creates a new HTTP server listening for loopback traffic on the given port, starts it, and runs the server until the server processes a shutdown request, spinning an event loop so that events posted by the server's socket are processed.

This method is primarily intended for use in running this script from within xpcshell and running a functional HTTP server without having to deal with non-essential details.

Note that running multiple servers using variants of this method probably doesn't work, simply due to how the internal event loop is spun and stopped.

Note
This method only works with Mozilla 1.9 (i.e., Firefox 3 or trunk code); you should use this server as a component in Mozilla 1.8.
Parameters
portthe port on which the server will run, or -1 if there exists no preference for a specific port; note that attempting to use some values for this parameter (particularly those below 1024) may cause this method to throw or may result in the server being prematurely shut down
basePatha local directory from which requests will be served (i.e., if this is "/home/jwalden/" then a request to /index.html will load /home/jwalden/index.html); if this is omitted, only the default URLs in this server implementation will be functional

Definition at line 4758 of file httpd.js.

Here is the call graph for this function:

Here is the caller graph for this function:

function ServerHandler (   server)

An object which handles requests for a server, executing default and overridden behaviors as instructed by the code which uses and manipulates it. Default behavior includes the paths / and /trace (diagnostics), with some support for HTTP error pages for various codes and fallback to HTTP 500 if those codes fail for any reason.

Parameters
server: nsHttpServer the server in which this handler is being used

The nsHttpServer instance associated with this handler.

A FileMap object containing the set of path->nsILocalFile mappings for all directory mappings set in the server (e.g., "/" for /var/www/html/, "/foo/bar/" for /local/path/, and "/foo/bar/baz/" for /local/path2).

Note carefully: the leading and trailing "/" in each path (not file) are removed before insertion to simplify the code which uses this. You have been warned!

Custom request handlers for the server in which this resides. Path-handler pairs are stored as property-value pairs in this property.

See Also
ServerHandler.prototype._defaultPaths

Custom request handlers for the path prefixes on the server in which this resides. Path-handler pairs are stored as property-value pairs in this property.

See Also
ServerHandler.prototype._defaultPaths

Custom request handlers for the error handlers in the server in which this resides. Path-handler pairs are stored as property-value pairs in this property.

See Also
ServerHandler.prototype._defaultErrors

Maps file extensions to their MIME types in the server, overriding any mapping that might or might not exist in the MIME service.

The default handler for requests for directories, used to serve directories when no index file is present.

Per-path state storage for the server.

Entire-server state storage.

Entire-server state storage for nsISupports values.

Definition at line 2101 of file httpd.js.

Here is the call graph for this function:

Here is the caller graph for this function:

function ServerIdentity ( )

Represents the identity of a server. An identity consists of a set of (scheme, host, port) tuples denoted as locations (allowing a single server to serve multiple sites or to be used behind both HTTP and HTTPS proxies for any host/port). Any incoming request must be to one of these locations, or it will be rejected with an HTTP 400 error. One location, denoted as the primary location, is the location assigned in contexts where a location cannot otherwise be endogenously derived, such as for HTTP/1.0 requests.

A single identity may contain at most one location per unique host/port pair; other than that, no restrictions are placed upon what locations may constitute an identity.

The scheme of the primary location.

The hostname of the primary location.

The port number of the primary location.

The current port number for the corresponding server, stored so that a new primary location can always be set if the current one is removed.

Maps hosts to maps of ports to schemes, e.g. the following would represent https://example.com:789/ and http://example.org/:

{ "xexample.com": { 789: "https" }, "xexample.org": { 80: "http" } }

Note the "x" prefix on hostnames, which prevents collisions with special JS names like "prototype".

Definition at line 811 of file httpd.js.

Here is the caller graph for this function:

function toDateString (   date)

Returns the RFC 822/1123 representation of a date.

Parameters
date: Number the date, in milliseconds from midnight (00:00:00), January 1, 1970 GMT
Returns
string the representation of the given date

Processes a date and returns the encoded UTC time as a string according to the format specified in RFC 2616.

Parameters
date: Date the date to process
Returns
string a string of the form "HH:MM:SS", ranging from "00:00:00" to "23:59:59"

Processes a date and returns the encoded UTC date as a string according to the date1 format specified in RFC 2616.

Parameters
date: Date the date to process
Returns
string a string of the form "HH:MM:SS", ranging from "00:00:00" to "23:59:59"

Definition at line 242 of file httpd.js.

function toInternalPath (   path,
  encoded 
)

Converts an externally-provided path into an internal path for use in determining file mappings.

Parameters
paththe path to convert
encodedtrue if the given path should be passed through decodeURI prior to conversion
Exceptions
URIErrorif path is incorrectly encoded

Definition at line 1983 of file httpd.js.

function WriteThroughCopier (   input,
  output,
  observer,
  context 
)

Copies data from input to output as it becomes available.

Parameters
input: nsIAsyncInputStream the stream from which data is to be read
output: nsIOutputStream the stream to which data is to be copied
observer: nsIRequestObserver an observer which will be notified when the copy starts and finishes
context: nsISupports context passed to observer when notified of start/stop
Exceptions
NS_ERROR_NULL_POINTERif input, output, or observer are null

Stream from which data is being read.

Stream to which data is being written.

Observer watching this copy.

Context for the observer watching this.

False until cancel() is called, when this copy is completed.

Required by nsIRequest, meaningless.

Required by nsIRequest, meaningless.

Required by nsIRequest, meaningless.

Status of this request.

Definition at line 3949 of file httpd.js.

Here is the call graph for this function:

Variable Documentation

const BinaryInputStream
Initial value:
= CC("@mozilla.org/binaryinputstream;1",
"nsIBinaryInputStream",
"setInputStream")
const CC
Definition: httpd.js:53

Definition at line 210 of file httpd.js.

const BinaryOutputStream
Initial value:
= CC("@mozilla.org/binaryoutputstream;1",
"nsIBinaryOutputStream",
"setOutputStream")
const CC
Definition: httpd.js:53

Definition at line 213 of file httpd.js.

const Cc = Components.classes

Definition at line 49 of file httpd.js.

const CC = Components.Constructor

Definition at line 53 of file httpd.js.

Definition at line 50 of file httpd.js.

const ConverterInputStream
Initial value:
= CC("@mozilla.org/intl/converter-input-stream;1",
"nsIConverterInputStream",
"init")
const CC
Definition: httpd.js:53

Definition at line 225 of file httpd.js.

const Cr = Components.results

Definition at line 51 of file httpd.js.

const CR = 0x0D

The character codes for CR and LF.

Definition at line 1780 of file httpd.js.

const Cu = Components.utils

Definition at line 52 of file httpd.js.

var DEBUG = false

True if debugging output is enabled, false otherwise.

Definition at line 60 of file httpd.js.

const EXPORTED_SYMBOLS = ["server", "nsHttpServer", "HttpError"]

Definition at line 57 of file httpd.js.

const FileInputStream
Initial value:
= CC("@mozilla.org/network/file-input-stream;1",
"nsIFileInputStream",
"init")
const CC
Definition: httpd.js:53

Definition at line 222 of file httpd.js.

var gGlobalObject = this

Definition at line 62 of file httpd.js.

var gRootPrefBranch = null

The XPCOM prefs service.

Definition at line 191 of file httpd.js.

var gThreadManager = null

The XPCOM thread manager.

Definition at line 188 of file httpd.js.

const HEADERS_SUFFIX = HIDDEN_CHAR + "headers" + HIDDEN_CHAR

The file name suffix indicating the file containing overridden headers for a requested file.

Definition at line 165 of file httpd.js.

const headerUtils

A container for utility functions used with HTTP headers.

Definition at line 4115 of file httpd.js.

const HIDDEN_CHAR = "^"

The character used to distinguish hidden files from non-hidden files, a la the leading dot in Apache. Since that mechanism also hides files from easy display in LXR, ls output, etc. however, we choose instead to use a suffix character. If a requested file ends with it, we append another when getting the file on the server. If it doesn't, we just look up that file. Therefore, any file whose name ends with exactly one of the character is "hidden" and available for use by the server.

Definition at line 159 of file httpd.js.

const HOST_REGEX
Initial value:
=
new RegExp("^(?:" +
"(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)*" +
"[a-z](?:[a-z0-9-]*[a-z0-9])?" +
"|" +
"\\d+\\.\\d+\\.\\d+\\.\\d+" +
")$",
"i")

Definition at line 785 of file httpd.js.

nsHttpVersion HTTP_1_0 = new nsHttpVersion("1.0")

Definition at line 4272 of file httpd.js.

nsHttpVersion HTTP_1_1 = new nsHttpVersion("1.1")

Definition at line 4273 of file httpd.js.

const HTTP_400 = new HttpError(400, "Bad Request")

Errors thrown to trigger specific HTTP server responses.

Definition at line 102 of file httpd.js.

const HTTP_401 = new HttpError(401, "Unauthorized")

Definition at line 103 of file httpd.js.

const HTTP_402 = new HttpError(402, "Payment Required")

Definition at line 104 of file httpd.js.

const HTTP_403 = new HttpError(403, "Forbidden")

Definition at line 105 of file httpd.js.

const HTTP_404 = new HttpError(404, "Not Found")

Definition at line 106 of file httpd.js.

const HTTP_405 = new HttpError(405, "Method Not Allowed")

Definition at line 107 of file httpd.js.

const HTTP_406 = new HttpError(406, "Not Acceptable")

Definition at line 108 of file httpd.js.

const HTTP_407 = new HttpError(407, "Proxy Authentication Required")

Definition at line 109 of file httpd.js.

const HTTP_408 = new HttpError(408, "Request Timeout")

Definition at line 110 of file httpd.js.

const HTTP_409 = new HttpError(409, "Conflict")

Definition at line 111 of file httpd.js.

const HTTP_410 = new HttpError(410, "Gone")

Definition at line 112 of file httpd.js.

const HTTP_411 = new HttpError(411, "Length Required")

Definition at line 113 of file httpd.js.

const HTTP_412 = new HttpError(412, "Precondition Failed")

Definition at line 114 of file httpd.js.

const HTTP_413 = new HttpError(413, "Request Entity Too Large")

Definition at line 115 of file httpd.js.

const HTTP_414 = new HttpError(414, "Request-URI Too Long")

Definition at line 116 of file httpd.js.

const HTTP_415 = new HttpError(415, "Unsupported Media Type")

Definition at line 117 of file httpd.js.

const HTTP_416 = new HttpError(416, "Requested Range Not Satisfiable")

Definition at line 118 of file httpd.js.

const HTTP_417 = new HttpError(417, "Expectation Failed")

Definition at line 119 of file httpd.js.

const HTTP_500 = new HttpError(500, "Internal Server Error")

Definition at line 121 of file httpd.js.

const HTTP_501 = new HttpError(501, "Not Implemented")

Definition at line 122 of file httpd.js.

const HTTP_502 = new HttpError(502, "Bad Gateway")

Definition at line 123 of file httpd.js.

const HTTP_503 = new HttpError(503, "Service Unavailable")

Definition at line 124 of file httpd.js.

const HTTP_504 = new HttpError(504, "Gateway Timeout")

Definition at line 125 of file httpd.js.

const HTTP_505 = new HttpError(505, "HTTP Version Not Supported")

Definition at line 126 of file httpd.js.

const HTTP_ERROR_CODES = array2obj(range(400, 417).concat(range(500, 505)))

An object (hash) whose fields are the numbers of all HTTP error codes.

Definition at line 147 of file httpd.js.

const IS_TOKEN_ARRAY
Initial value:
=
[0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 1, 0, 1, 1, 1, 1, 1,
0, 0, 1, 1, 0, 1, 1, 0,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 0, 0, 0, 0, 0, 0,
0, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 0, 0, 0, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 0, 1, 0, 1]

Definition at line 3291 of file httpd.js.

const LF = 0x0A

Definition at line 1780 of file httpd.js.

const module

The XPCOM module containing the HTTP server.

Definition at line 4659 of file httpd.js.

const Pipe
Initial value:
= CC("@mozilla.org/pipe;1",
"nsIPipe",
"init")
const CC
Definition: httpd.js:53

Definition at line 219 of file httpd.js.

const PR_UINT32_MAX = Math.pow(2, 32) - 1

Definition at line 55 of file httpd.js.

Request prototype
Initial value:
=
{
toString: function()
{
return this.code + " " + this.description;
}
}

Definition at line 91 of file httpd.js.

const READER_FINISHED = 3

Definition at line 1159 of file httpd.js.

const READER_IN_BODY = 2

Definition at line 1158 of file httpd.js.

const READER_IN_HEADERS = 1

Definition at line 1157 of file httpd.js.

const READER_IN_REQUEST_LINE = 0

Request reader processing states; see RequestReader for details.

Definition at line 1156 of file httpd.js.

const ScriptableInputStream
Initial value:
= CC("@mozilla.org/scriptableinputstream;1",
"nsIScriptableInputStream",
"init")
const CC
Definition: httpd.js:53

Definition at line 216 of file httpd.js.

Response SEGMENT_SIZE = 8192

Size of the segments in the buffer used in storing response data and writing it to the socket.

Definition at line 3927 of file httpd.js.

const ServerSocket
Initial value:
= CC("@mozilla.org/network/server-socket;1",
"nsIServerSocket",
"init")
const CC
Definition: httpd.js:53

JavaScript constructors for commonly-used classes; precreating these is a speedup over doing the same from base principles. See the docs at http://developer.mozilla.org/en/docs/Components.Constructor for details.

Definition at line 207 of file httpd.js.

const SJS_TYPE = "sjs"

Type used to denote SJS scripts for CGI-like functionality.

Definition at line 168 of file httpd.js.

const SupportsString
Initial value:
= CC("@mozilla.org/supports-string;1",
"nsISupportsString")
const CC
Definition: httpd.js:53

Definition at line 230 of file httpd.js.

const WritablePropertyBag
Initial value:
= CC("@mozilla.org/hash-property-bag;1",
"nsIWritablePropertyBag2")
const CC
Definition: httpd.js:53

Definition at line 228 of file httpd.js.