Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Out of service — Please use Q-IO
JavaScript

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
test
.gitignore
CHANGES
LICENSE
README
package.json
q-http.js

README

Provides a Q promise API for HTTP requests and responses.  This should
resemble JSGI and its hypothetical inverse, but I haven't pored
through the specification to ensure this.

The API

    Server(respond(request):Response*)
        listen(port:Number):Server*
        stop():Undefined*

    read(url:String):String
    read(request:Request):String
    request(url:String):Response*
    request(request:Request):Response*

    {Client,Server}Request:Object

        url:String the full URL, regardless of routing
        path:String the full path, regardless of routing
        scriptName:String the routed portion
            of the path, e.g., "" for the
            root document
        pathInfo:String the part of the path
            that remains to be routed, e.g.,
            "/" for the root document
        version:Array HTTP version
        scheme:String e.g., "http"
        method:String e.g., "GET"
        host:String
        port:Number
        remoteHost:String
        remotePort:Number
        headers:Object
        body*
            forEach(write(String*)):Undefined*
        node the wrapped Node request object

    {Client,Server}Response:Object

        status:Number
        headers:Object
        body*
            forEach(write(String*)):Undefined*
        onclose:Function?
        node the wrapped Node response object

Conventions

    `*` indicates that a value may be a promise
    `?` indicates optional

Copyright 2009, 2010, 2011 Kristopher Michael Kowal
MIT License (enclosed)

Something went wrong with that request. Please try again.