almost rebased

This commit is contained in:
2013-01-14 18:22:57 -05:00
parent f6d1b95d0b
commit 9c33416a92
626 changed files with 101228 additions and 0 deletions

55
test/node_modules/request/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,55 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
You must give any other recipients of the Work or Derivative Works a copy of this License; and
You must cause any modified files to carry prominent notices stating that You changed the files; and
You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS

287
test/node_modules/request/README.md generated vendored Normal file
View File

@@ -0,0 +1,287 @@
# Request -- Simplified HTTP request method
## Install
<pre>
npm install request
</pre>
Or from source:
<pre>
git clone git://github.com/mikeal/request.git
cd request
npm link
</pre>
## Super simple to use
Request is designed to be the simplest way possible to make http calls. It supports HTTPS and follows redirects by default.
```javascript
var request = require('request');
request('http://www.google.com', function (error, response, body) {
if (!error && response.statusCode == 200) {
console.log(body) // Print the google web page.
}
})
```
## Streaming
You can stream any response to a file stream.
```javascript
request('http://google.com/doodle.png').pipe(fs.createWriteStream('doodle.png'))
```
You can also stream a file to a PUT or POST request. This method will also check the file extension against a mapping of file extensions to content-types, in this case `application/json`, and use the proper content-type in the PUT request if one is not already provided in the headers.
```javascript
fs.createReadStream('file.json').pipe(request.put('http://mysite.com/obj.json'))
```
Request can also pipe to itself. When doing so the content-type and content-length will be preserved in the PUT headers.
```javascript
request.get('http://google.com/img.png').pipe(request.put('http://mysite.com/img.png'))
```
Now let's get fancy.
```javascript
http.createServer(function (req, resp) {
if (req.url === '/doodle.png') {
if (req.method === 'PUT') {
req.pipe(request.put('http://mysite.com/doodle.png'))
} else if (req.method === 'GET' || req.method === 'HEAD') {
request.get('http://mysite.com/doodle.png').pipe(resp)
}
}
})
```
You can also pipe() from a http.ServerRequest instance and to a http.ServerResponse instance. The HTTP method and headers will be sent as well as the entity-body data. Which means that, if you don't really care about security, you can do:
```javascript
http.createServer(function (req, resp) {
if (req.url === '/doodle.png') {
var x = request('http://mysite.com/doodle.png')
req.pipe(x)
x.pipe(resp)
}
})
```
And since pipe() returns the destination stream in node 0.5.x you can do one line proxying :)
```javascript
req.pipe(request('http://mysite.com/doodle.png')).pipe(resp)
```
Also, none of this new functionality conflicts with requests previous features, it just expands them.
```javascript
var r = request.defaults({'proxy':'http://localproxy.com'})
http.createServer(function (req, resp) {
if (req.url === '/doodle.png') {
r.get('http://google.com/doodle.png').pipe(resp)
}
})
```
You can still use intermediate proxies, the requests will still follow HTTP forwards, etc.
## OAuth Signing
```javascript
// Twitter OAuth
var qs = require('querystring')
, oauth =
{ callback: 'http://mysite.com/callback/'
, consumer_key: CONSUMER_KEY
, consumer_secret: CONSUMER_SECRET
}
, url = 'https://api.twitter.com/oauth/request_token'
;
request.post({url:url, oauth:oauth}, function (e, r, body) {
// Assume by some stretch of magic you aquired the verifier
var access_token = qs.parse(body)
, oauth =
{ consumer_key: CONSUMER_KEY
, consumer_secret: CONSUMER_SECRET
, token: access_token.oauth_token
, verifier: VERIFIER
, token_secret: access_token.oauth_token_secret
}
, url = 'https://api.twitter.com/oauth/access_token'
;
request.post({url:url, oauth:oauth}, function (e, r, body) {
var perm_token = qs.parse(body)
, oauth =
{ consumer_key: CONSUMER_KEY
, consumer_secret: CONSUMER_SECRET
, token: perm_token.oauth_token
, token_secret: perm_token.oauth_token_secret
}
, url = 'https://api.twitter.com/1/users/show.json?'
, params =
{ screen_name: perm_token.screen_name
, user_id: perm_token.user_id
}
;
url += qs.stringify(params)
request.get({url:url, oauth:oauth, json:true}, function (e, r, user) {
console.log(user)
})
})
})
```
### request(options, callback)
The first argument can be either a url or an options object. The only required option is uri, all others are optional.
* `uri` || `url` - fully qualified uri or a parsed url object from url.parse()
* `qs` - object containing querystring values to be appended to the uri
* `method` - http method, defaults to GET
* `headers` - http headers, defaults to {}
* `body` - entity body for POST and PUT requests. Must be buffer or string.
* `form` - sets `body` but to querystring representation of value and adds `Content-type: application/x-www-form-urlencoded; charset=utf-8` header.
* `json` - sets `body` but to JSON representation of value and adds `Content-type: application/json` header. Additionally, parses the response body as json.
* `multipart` - (experimental) array of objects which contains their own headers and `body` attribute. Sends `multipart/related` request. See example below.
* `followRedirect` - follow HTTP 3xx responses as redirects. defaults to true.
* `followAllRedirects` - follow non-GET HTTP 3xx responses as redirects. defaults to false.
* `maxRedirects` - the maximum number of redirects to follow, defaults to 10.
* `encoding` - Encoding to be used on `setEncoding` of response data. If set to `null`, the body is returned as a Buffer.
* `pool` - A hash object containing the agents for these requests. If omitted this request will use the global pool which is set to node's default maxSockets.
* `pool.maxSockets` - Integer containing the maximum amount of sockets in the pool.
* `timeout` - Integer containing the number of milliseconds to wait for a request to respond before aborting the request
* `proxy` - An HTTP proxy to be used. Support proxy Auth with Basic Auth the same way it's supported with the `url` parameter by embedding the auth info in the uri.
* `oauth` - Options for OAuth HMAC-SHA1 signing, see documentation above.
* `strictSSL` - Set to `true` to require that SSL certificates be valid. Note: to use your own certificate authority, you need to specify an agent that was created with that ca as an option.
* `jar` - Set to `false` if you don't want cookies to be remembered for future use or define your custom cookie jar (see examples section)
The callback argument gets 3 arguments. The first is an error when applicable (usually from the http.Client option not the http.ClientRequest object). The second in an http.ClientResponse object. The third is the response body String or Buffer.
## Convenience methods
There are also shorthand methods for different HTTP METHODs and some other conveniences.
### request.defaults(options)
This method returns a wrapper around the normal request API that defaults to whatever options you pass in to it.
### request.put
Same as request() but defaults to `method: "PUT"`.
```javascript
request.put(url)
```
### request.post
Same as request() but defaults to `method: "POST"`.
```javascript
request.post(url)
```
### request.head
Same as request() but defaults to `method: "HEAD"`.
```javascript
request.head(url)
```
### request.del
Same as request() but defaults to `method: "DELETE"`.
```javascript
request.del(url)
```
### request.get
Alias to normal request method for uniformity.
```javascript
request.get(url)
```
### request.cookie
Function that creates a new cookie.
```javascript
request.cookie('cookie_string_here')
```
### request.jar
Function that creates a new cookie jar.
```javascript
request.jar()
```
## Examples:
```javascript
var request = require('request')
, rand = Math.floor(Math.random()*100000000).toString()
;
request(
{ method: 'PUT'
, uri: 'http://mikeal.iriscouch.com/testjs/' + rand
, multipart:
[ { 'content-type': 'application/json'
, body: JSON.stringify({foo: 'bar', _attachments: {'message.txt': {follows: true, length: 18, 'content_type': 'text/plain' }}})
}
, { body: 'I am an attachment' }
]
}
, function (error, response, body) {
if(response.statusCode == 201){
console.log('document saved as: http://mikeal.iriscouch.com/testjs/'+ rand)
} else {
console.log('error: '+ response.statusCode)
console.log(body)
}
}
)
```
Cookies are enabled by default (so they can be used in subsequent requests). To disable cookies set jar to false (either in defaults or in the options sent).
```javascript
var request = request.defaults({jar: false})
request('http://www.google.com', function () {
request('http://images.google.com')
})
```
If you to use a custom cookie jar (instead of letting request use its own global cookie jar) you do so by setting the jar default or by specifying it as an option:
```javascript
var j = request.jar()
var request = request.defaults({jar:j})
request('http://www.google.com', function () {
request('http://images.google.com')
})
```
OR
```javascript
var j = request.jar()
var cookie = request.cookie('your_cookie_here')
j.add(cookie)
request({url: 'http://www.google.com', jar: j}, function () {
request('http://images.google.com')
})
```

190
test/node_modules/request/aws.js generated vendored Normal file
View File

@@ -0,0 +1,190 @@
/*!
* knox - auth
* Copyright(c) 2010 LearnBoost <dev@learnboost.com>
* MIT Licensed
*/
/**
* Module dependencies.
*/
var crypto = require('crypto')
, parse = require('url').parse;
/**
* Valid keys.
*/
var keys = [
'acl'
, 'location'
, 'logging'
, 'notification'
, 'partNumber'
, 'policy'
, 'requestPayment'
, 'torrent'
, 'uploadId'
, 'uploads'
, 'versionId'
, 'versioning'
, 'versions'
, 'website'
];
/**
* Return an "Authorization" header value with the given `options`
* in the form of "AWS <key>:<signature>"
*
* @param {Object} options
* @return {String}
* @api private
*/
exports.authorization = function(options){
return 'AWS ' + options.key + ':' + exports.sign(options);
};
/**
* Simple HMAC-SHA1 Wrapper
*
* @param {Object} options
* @return {String}
* @api private
*/
exports.hmacSha1 = function(options){
return crypto.createHmac('sha1', options.secret).update(options.message).digest('base64');
};
/**
* Create a base64 sha1 HMAC for `options`.
*
* @param {Object} options
* @return {String}
* @api private
*/
exports.sign = function(options){
options.message = exports.stringToSign(options);
return exports.hmacSha1(options);
};
/**
* Create a base64 sha1 HMAC for `options`.
*
* Specifically to be used with S3 presigned URLs
*
* @param {Object} options
* @return {String}
* @api private
*/
exports.signQuery = function(options){
options.message = exports.queryStringToSign(options);
return exports.hmacSha1(options);
};
/**
* Return a string for sign() with the given `options`.
*
* Spec:
*
* <verb>\n
* <md5>\n
* <content-type>\n
* <date>\n
* [headers\n]
* <resource>
*
* @param {Object} options
* @return {String}
* @api private
*/
exports.stringToSign = function(options){
var headers = options.amazonHeaders || '';
if (headers) headers += '\n';
return [
options.verb
, options.md5
, options.contentType
, options.date.toUTCString()
, headers + options.resource
].join('\n');
};
/**
* Return a string for sign() with the given `options`, but is meant exclusively
* for S3 presigned URLs
*
* Spec:
*
* <date>\n
* <resource>
*
* @param {Object} options
* @return {String}
* @api private
*/
exports.queryStringToSign = function(options){
return 'GET\n\n\n' +
options.date + '\n' +
options.resource;
};
/**
* Perform the following:
*
* - ignore non-amazon headers
* - lowercase fields
* - sort lexicographically
* - trim whitespace between ":"
* - join with newline
*
* @param {Object} headers
* @return {String}
* @api private
*/
exports.canonicalizeHeaders = function(headers){
var buf = []
, fields = Object.keys(headers);
for (var i = 0, len = fields.length; i < len; ++i) {
var field = fields[i]
, val = headers[field]
, field = field.toLowerCase();
if (0 !== field.indexOf('x-amz')) continue;
buf.push(field + ':' + val);
}
return buf.sort().join('\n');
};
/**
* Perform the following:
*
* - ignore non sub-resources
* - sort lexicographically
*
* @param {String} resource
* @return {String}
* @api private
*/
exports.canonicalizeResource = function(resource){
var url = parse(resource, true)
, path = url.pathname
, buf = [];
Object.keys(url.query).forEach(function(key){
if (!~keys.indexOf(key)) return;
var val = '' == url.query[key] ? '' : '=' + encodeURIComponent(url.query[key]);
buf.push(key + val);
});
return path + (buf.length
? '?' + buf.sort().join('&')
: '');
};

128
test/node_modules/request/aws2.js generated vendored Normal file
View File

@@ -0,0 +1,128 @@
var crypto = require('crypto')
// The Authentication Header
//
// The Amazon S3 REST API uses the standard HTTPAuthorization header to pass authentication information. (The name of the standard header is unfortunate because it carries authentication information, not authorization).Under the Amazon S3 authentication scheme, the Authorization header has the following form.
//
// Authorization: AWS AWSAccessKeyId:Signature
//
// Developers are issued an AWS Access Key ID and AWS SecretAccess Key when they register. For request authentication, theAWSAccessKeyId element identifies the secret key that was used to compute the signature, and (indirectly) the developer making the request.
//
// The Signature element is the RFC 2104HMAC-SHA1 of selected elements from the request, and so theSignature part of the Authorization header will vary from request to request. If the request signature calculated by the system matches theSignature included with the request, then the requester will have demonstrated possession to the AWSSecret Access Key. The request will then be processed under the identity, and with the authority, of the developer to whom the key was issued.
//
// Following is pseudo-grammar that illustrates the construction of the Authorization request header (\nmeans the Unicode code point U+000A commonly called newline).
function authorizationHeader (accessKey) {
// Authorization = "AWS" + " " + AWSAccessKeyId + ":" + Signature;
var authorization = 'AWS' + " " + accessKey + ":" + signature()
return authorization
}
//
function signature (secret, verb, md5, contenttype, date, amzheaders, bucket, path) {
// Signature = Base64( HMAC-SHA1( UTF-8-Encoding-Of( YourSecretAccessKeyID, StringToSign ) ) );
function encodeSignature (stringToSign) {
return crypto.createHash('sha1').update(stringToSign).digest('base64')
}
//
// StringToSign = HTTP-Verb + "\n" +
// Content-MD5 + "\n" +
// Content-Type + "\n" +
// Date + "\n" +
// CanonicalizedAmzHeaders +
// CanonicalizedResource;
function compileStringToSign () {
var s =
verb + '\n'
(md5 || '') + '\n'
(contenttype || '') + '\n'
date.toUTCString() + '\n'
canonicalizeAmzHeaders(amzheaders) +
canonicalizeResource()
return s
}
//
// CanonicalizedResource = [ "/" + Bucket ] +
// <HTTP-Request-URI, from the protocol name up to the query string> +
// [ sub-resource, if present. For example "?acl", "?location", "?logging", or "?torrent"];
function canonicalizeResource () {
return '/' + bucket + path
}
//
// CanonicalizedAmzHeaders = <described below>
//
// HMAC-SHA1 is an algorithm defined by RFC 2104 (go to RFC 2104 - Keyed-Hashing for Message Authentication ). The algorithm takes as input two byte-strings: a key and a message. For Amazon S3 Request authentication, use your AWS Secret Access Key (YourSecretAccessKeyID) as the key, and the UTF-8 encoding of the StringToSign as the message. The output of HMAC-SHA1 is also a byte string, called the digest. The Signature request parameter is constructed by Base64 encoding this digest.
// Request Canonicalization for Signing
//
// Recall that when the system receives an authenticated request, it compares the computed request signature with the signature provided in the request in StringToSign. For that reason, you must compute the signature using the same method used by Amazon S3. We call the process of putting a request in an agreed-upon form for signing "canonicalization".
}
// Constructing the CanonicalizedResource Element
//
// CanonicalizedResource represents the Amazon S3 resource targeted by the request. Construct it for a REST request as follows:
//
// Launch Process
//
// 1
//
//
// Start with the empty string ("").
//
// 2
//
//
// If the request specifies a bucket using the HTTP Host header (virtual hosted-style), append the bucket name preceded by a "/" (e.g., "/bucketname"). For path-style requests and requests that don't address a bucket, do nothing. For more information on virtual hosted-style requests, see Virtual Hosting of Buckets.
//
// 3
//
//
// Append the path part of the un-decoded HTTP Request-URI, up-to but not including the query string.
//
// 4
//
//
// If the request addresses a sub-resource, like ?versioning, ?location, ?acl, ?torrent, ?lifecycle, or ?versionid append the sub-resource, its value if it has one, and the question mark. Note that in case of multiple sub-resources, sub-resources must be lexicographically sorted by sub-resource name and separated by '&'. e.g. ?acl&versionId=value.
//
// The list of sub-resources that must be included when constructing the CanonicalizedResource Element are: acl, lifecycle, location, logging, notification, partNumber, policy, requestPayment, torrent, uploadId, uploads, versionId, versioning, versions and website.
//
// If the request specifies query string parameters overriding the response header values (see Get Object), append the query string parameters, and its values. When signing you do not encode these values. However, when making the request, you must encode these parameter values. The query string parameters in a GET request include response-content-type, response-content-language, response-expires, response-cache-control, response-content-disposition, response-content-encoding.
//
// The delete query string parameter must be including when creating the CanonicalizedResource for a Multi-Object Delete request.
//
// Elements of the CanonicalizedResource that come from the HTTP Request-URI should be signed literally as they appear in the HTTP request, including URL-Encoding meta characters.
//
// The CanonicalizedResource might be different than the HTTP Request-URI. In particular, if your request uses the HTTP Host header to specify a bucket, the bucket does appear in the HTTP Request-URI. However, the CanonicalizedResource continues to include the bucket. Query string parameters might also appear in the Request-URI but are not included in CanonicalizedResource. For more information, see Virtual Hosting of Buckets.
// Constructing the CanonicalizedAmzHeaders Element
//
// To construct the CanonicalizedAmzHeaders part of StringToSign, select all HTTP request headers that start with 'x-amz-' (using a case-insensitive comparison) and use the following process.
//
// CanonicalizedAmzHeaders Process
// 1 Convert each HTTP header name to lower-case. For example, 'X-Amz-Date' becomes 'x-amz-date'.
// 2 Sort the collection of headers lexicographically by header name.
// 3 Combine header fields with the same name into one "header-name:comma-separated-value-list" pair as prescribed by RFC 2616, section 4.2, without any white-space between values. For example, the two metadata headers 'x-amz-meta-username: fred' and 'x-amz-meta-username: barney' would be combined into the single header 'x-amz-meta-username: fred,barney'.
// 4 "Unfold" long headers that span multiple lines (as allowed by RFC 2616, section 4.2) by replacing the folding white-space (including new-line) by a single space.
// 5 Trim any white-space around the colon in the header. For example, the header 'x-amz-meta-username: fred,barney' would become 'x-amz-meta-username:fred,barney'
// 6 Finally, append a new-line (U+000A) to each canonicalized header in the resulting list. Construct the CanonicalizedResource element by concatenating all headers in this list into a single string.
//
// Positional versus Named HTTP Header StringToSign Elements
//
// The first few header elements of StringToSign (Content-Type, Date, and Content-MD5) are positional in nature. StringToSign does not include the names of these headers, only their values from the request. In contrast, the 'x-amz-' elements are named; Both the header names and the header values appear in StringToSign.
//
// If a positional header called for in the definition of StringToSign is not present in your request, (Content-Type or Content-MD5, for example, are optional for PUT requests, and meaningless for GET requests), substitute the empty string ("") in for that position.
// Time Stamp Requirement
//
// A valid time stamp (using either the HTTP Date header or an x-amz-date alternative) is mandatory for authenticated requests. Furthermore, the client time-stamp included with an authenticated request must be within 15 minutes of the Amazon S3 system time when the request is received. If not, the request will fail with the RequestTimeTooSkewed error status code. The intention of these restrictions is to limit the possibility that intercepted requests could be replayed by an adversary. For stronger protection against eavesdropping, use the HTTPS transport for authenticated requests.
//
// Some HTTP client libraries do not expose the ability to set the Date header for a request. If you have trouble including the value of the 'Date' header in the canonicalized headers, you can set the time-stamp for the request using an 'x-amz-date' header instead. The value of the x-amz-date header must be in one of the RFC 2616 formats (http://www.ietf.org/rfc/rfc2616.txt). When an x-amz-date header is present in a request, the system will ignore any Date header when computing the request signature. Therefore, if you include the x-amz-date header, use the empty string for the Date when constructing the StringToSign. See the next section for an example.

103
test/node_modules/request/forever.js generated vendored Normal file
View File

@@ -0,0 +1,103 @@
module.exports = ForeverAgent
ForeverAgent.SSL = ForeverAgentSSL
var util = require('util')
, Agent = require('http').Agent
, net = require('net')
, tls = require('tls')
, AgentSSL = require('https').Agent
function ForeverAgent(options) {
var self = this
self.options = options || {}
self.requests = {}
self.sockets = {}
self.freeSockets = {}
self.maxSockets = self.options.maxSockets || Agent.defaultMaxSockets
self.minSockets = self.options.minSockets || ForeverAgent.defaultMinSockets
self.on('free', function(socket, host, port) {
var name = host + ':' + port
if (self.requests[name] && self.requests[name].length) {
self.requests[name].shift().onSocket(socket)
} else if (self.sockets[name].length < self.minSockets) {
if (!self.freeSockets[name]) self.freeSockets[name] = []
self.freeSockets[name].push(socket)
// if an error happens while we don't use the socket anyway, meh, throw the socket away
function onIdleError() {
socket.destroy()
}
socket._onIdleError = onIdleError
socket.on('error', onIdleError)
} else {
// If there are no pending requests just destroy the
// socket and it will get removed from the pool. This
// gets us out of timeout issues and allows us to
// default to Connection:keep-alive.
socket.destroy();
}
})
}
util.inherits(ForeverAgent, Agent)
ForeverAgent.defaultMinSockets = 5
ForeverAgent.prototype.createConnection = net.createConnection
ForeverAgent.prototype.addRequestNoreuse = Agent.prototype.addRequest
ForeverAgent.prototype.addRequest = function(req, host, port) {
var name = host + ':' + port
if (this.freeSockets[name] && this.freeSockets[name].length > 0 && !req.useChunkedEncodingByDefault) {
var idleSocket = this.freeSockets[name].pop()
idleSocket.removeListener('error', idleSocket._onIdleError)
delete idleSocket._onIdleError
req._reusedSocket = true
req.onSocket(idleSocket)
} else {
this.addRequestNoreuse(req, host, port)
}
}
ForeverAgent.prototype.removeSocket = function(s, name, host, port) {
if (this.sockets[name]) {
var index = this.sockets[name].indexOf(s);
if (index !== -1) {
this.sockets[name].splice(index, 1);
}
} else if (this.sockets[name] && this.sockets[name].length === 0) {
// don't leak
delete this.sockets[name];
delete this.requests[name];
}
if (this.freeSockets[name]) {
var index = this.freeSockets[name].indexOf(s)
if (index !== -1) {
this.freeSockets[name].splice(index, 1)
if (this.freeSockets[name].length === 0) {
delete this.freeSockets[name]
}
}
}
if (this.requests[name] && this.requests[name].length) {
// If we have pending requests and a socket gets closed a new one
// needs to be created to take over in the pool for the one that closed.
this.createSocket(name, host, port).emit('free');
}
}
function ForeverAgentSSL (options) {
ForeverAgent.call(this, options)
}
util.inherits(ForeverAgentSSL, ForeverAgent)
ForeverAgentSSL.prototype.createConnection = createConnectionSSL
ForeverAgentSSL.prototype.addRequestNoreuse = AgentSSL.prototype.addRequest
function createConnectionSSL (port, host, options) {
options.port = port
options.host = host
return tls.connect(options)
}

1067
test/node_modules/request/main.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

152
test/node_modules/request/mimetypes.js generated vendored Normal file
View File

@@ -0,0 +1,152 @@
// from http://github.com/felixge/node-paperboy
exports.types = {
"3gp":"video/3gpp",
"aiff":"audio/x-aiff",
"arj":"application/x-arj-compressed",
"asf":"video/x-ms-asf",
"asx":"video/x-ms-asx",
"au":"audio/ulaw",
"avi":"video/x-msvideo",
"bcpio":"application/x-bcpio",
"ccad":"application/clariscad",
"cod":"application/vnd.rim.cod",
"com":"application/x-msdos-program",
"cpio":"application/x-cpio",
"cpt":"application/mac-compactpro",
"csh":"application/x-csh",
"css":"text/css",
"deb":"application/x-debian-package",
"dl":"video/dl",
"doc":"application/msword",
"drw":"application/drafting",
"dvi":"application/x-dvi",
"dwg":"application/acad",
"dxf":"application/dxf",
"dxr":"application/x-director",
"etx":"text/x-setext",
"ez":"application/andrew-inset",
"fli":"video/x-fli",
"flv":"video/x-flv",
"gif":"image/gif",
"gl":"video/gl",
"gtar":"application/x-gtar",
"gz":"application/x-gzip",
"hdf":"application/x-hdf",
"hqx":"application/mac-binhex40",
"html":"text/html",
"ice":"x-conference/x-cooltalk",
"ico":"image/x-icon",
"ief":"image/ief",
"igs":"model/iges",
"ips":"application/x-ipscript",
"ipx":"application/x-ipix",
"jad":"text/vnd.sun.j2me.app-descriptor",
"jar":"application/java-archive",
"jpeg":"image/jpeg",
"jpg":"image/jpeg",
"js":"text/javascript",
"json":"application/json",
"latex":"application/x-latex",
"lsp":"application/x-lisp",
"lzh":"application/octet-stream",
"m":"text/plain",
"m3u":"audio/x-mpegurl",
"m4v":"video/mp4",
"man":"application/x-troff-man",
"me":"application/x-troff-me",
"midi":"audio/midi",
"mif":"application/x-mif",
"mime":"www/mime",
"mkv":" video/x-matrosk",
"movie":"video/x-sgi-movie",
"mp4":"video/mp4",
"mp41":"video/mp4",
"mp42":"video/mp4",
"mpg":"video/mpeg",
"mpga":"audio/mpeg",
"ms":"application/x-troff-ms",
"mustache":"text/plain",
"nc":"application/x-netcdf",
"oda":"application/oda",
"ogm":"application/ogg",
"pbm":"image/x-portable-bitmap",
"pdf":"application/pdf",
"pgm":"image/x-portable-graymap",
"pgn":"application/x-chess-pgn",
"pgp":"application/pgp",
"pm":"application/x-perl",
"png":"image/png",
"pnm":"image/x-portable-anymap",
"ppm":"image/x-portable-pixmap",
"ppz":"application/vnd.ms-powerpoint",
"pre":"application/x-freelance",
"prt":"application/pro_eng",
"ps":"application/postscript",
"qt":"video/quicktime",
"ra":"audio/x-realaudio",
"rar":"application/x-rar-compressed",
"ras":"image/x-cmu-raster",
"rgb":"image/x-rgb",
"rm":"audio/x-pn-realaudio",
"rpm":"audio/x-pn-realaudio-plugin",
"rtf":"text/rtf",
"rtx":"text/richtext",
"scm":"application/x-lotusscreencam",
"set":"application/set",
"sgml":"text/sgml",
"sh":"application/x-sh",
"shar":"application/x-shar",
"silo":"model/mesh",
"sit":"application/x-stuffit",
"skt":"application/x-koan",
"smil":"application/smil",
"snd":"audio/basic",
"sol":"application/solids",
"spl":"application/x-futuresplash",
"src":"application/x-wais-source",
"stl":"application/SLA",
"stp":"application/STEP",
"sv4cpio":"application/x-sv4cpio",
"sv4crc":"application/x-sv4crc",
"svg":"image/svg+xml",
"swf":"application/x-shockwave-flash",
"tar":"application/x-tar",
"tcl":"application/x-tcl",
"tex":"application/x-tex",
"texinfo":"application/x-texinfo",
"tgz":"application/x-tar-gz",
"tiff":"image/tiff",
"tr":"application/x-troff",
"tsi":"audio/TSP-audio",
"tsp":"application/dsptype",
"tsv":"text/tab-separated-values",
"unv":"application/i-deas",
"ustar":"application/x-ustar",
"vcd":"application/x-cdlink",
"vda":"application/vda",
"vivo":"video/vnd.vivo",
"vrm":"x-world/x-vrml",
"wav":"audio/x-wav",
"wax":"audio/x-ms-wax",
"webm":"video/webm",
"wma":"audio/x-ms-wma",
"wmv":"video/x-ms-wmv",
"wmx":"video/x-ms-wmx",
"wrl":"model/vrml",
"wvx":"video/x-ms-wvx",
"xbm":"image/x-xbitmap",
"xlw":"application/vnd.ms-excel",
"xml":"text/xml",
"xpm":"image/x-xpixmap",
"xwd":"image/x-xwindowdump",
"xyz":"chemical/x-pdb",
"zip":"application/zip"
};
exports.lookup = function(ext, defaultType) {
defaultType = defaultType || 'application/octet-stream';
return (ext in exports.types)
? exports.types[ext]
: defaultType;
};

34
test/node_modules/request/oauth.js generated vendored Normal file
View File

@@ -0,0 +1,34 @@
var crypto = require('crypto')
, qs = require('querystring')
;
function sha1 (key, body) {
return crypto.createHmac('sha1', key).update(body).digest('base64')
}
function rfc3986 (str) {
return encodeURIComponent(str)
.replace(/!/g,'%21')
.replace(/\*/g,'%2A')
.replace(/\(/g,'%28')
.replace(/\)/g,'%29')
.replace(/'/g,'%27')
;
}
function hmacsign (httpMethod, base_uri, params, consumer_secret, token_secret, body) {
// adapted from https://dev.twitter.com/docs/auth/oauth
var base =
(httpMethod || 'GET') + "&" +
encodeURIComponent( base_uri ) + "&" +
Object.keys(params).sort().map(function (i) {
// big WTF here with the escape + encoding but it's what twitter wants
return escape(rfc3986(i)) + "%3D" + escape(rfc3986(params[i]))
}).join("%26")
var key = encodeURIComponent(consumer_secret) + '&'
if (token_secret) key += encodeURIComponent(token_secret)
return sha1(key, base)
}
exports.hmacsign = hmacsign
exports.rfc3986 = rfc3986

36
test/node_modules/request/package.json generated vendored Normal file

File diff suppressed because one or more lines are too long

BIN
test/node_modules/request/tests/googledoodle.png generated vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

39
test/node_modules/request/tests/run.js generated vendored Normal file
View File

@@ -0,0 +1,39 @@
var spawn = require('child_process').spawn
, exitCode = 0
;
var tests = [
'test-body.js'
, 'test-cookie.js'
, 'test-cookiejar.js'
, 'test-defaults.js'
, 'test-errors.js'
, 'test-headers.js'
, 'test-httpModule.js'
, 'test-https.js'
, 'test-https-strict.js'
, 'test-oauth.js'
, 'test-pipes.js'
, 'test-pool.js'
, 'test-proxy.js'
, 'test-qs.js'
, 'test-redirect.js'
, 'test-timeout.js'
, 'test-toJSON.js'
, 'test-tunnel.js'
]
var next = function () {
if (tests.length === 0) process.exit(exitCode);
var file = tests.shift()
console.log(file)
var proc = spawn('node', [ 'tests/' + file ])
proc.stdout.pipe(process.stdout)
proc.stderr.pipe(process.stderr)
proc.on('exit', function (code) {
exitCode += code || 0
next()
})
}
next()

86
test/node_modules/request/tests/server.js generated vendored Normal file
View File

@@ -0,0 +1,86 @@
var fs = require('fs')
, http = require('http')
, path = require('path')
, https = require('https')
, events = require('events')
, stream = require('stream')
, assert = require('assert')
;
exports.createServer = function (port) {
port = port || 6767
var s = http.createServer(function (req, resp) {
s.emit(req.url, req, resp);
})
s.port = port
s.url = 'http://localhost:'+port
return s;
}
exports.createSSLServer = function(port, opts) {
port = port || 16767
var options = { 'key' : path.join(__dirname, 'ssl', 'test.key')
, 'cert': path.join(__dirname, 'ssl', 'test.crt')
}
if (opts) {
for (var i in opts) options[i] = opts[i]
}
for (var i in options) {
options[i] = fs.readFileSync(options[i])
}
var s = https.createServer(options, function (req, resp) {
s.emit(req.url, req, resp);
})
s.port = port
s.url = 'https://localhost:'+port
return s;
}
exports.createPostStream = function (text) {
var postStream = new stream.Stream();
postStream.writeable = true;
postStream.readable = true;
setTimeout(function () {postStream.emit('data', new Buffer(text)); postStream.emit('end')}, 0);
return postStream;
}
exports.createPostValidator = function (text) {
var l = function (req, resp) {
var r = '';
req.on('data', function (chunk) {r += chunk})
req.on('end', function () {
if (req.headers['content-type'] && req.headers['content-type'].indexOf('boundary=') >= 0) {
var boundary = req.headers['content-type'].split('boundary=')[1];
text = text.replace(/__BOUNDARY__/g, boundary);
}
if (r !== text) console.log(r, text);
assert.equal(r, text)
resp.writeHead(200, {'content-type':'text/plain'})
resp.write('OK')
resp.end()
})
}
return l;
}
exports.createGetResponse = function (text, contentType) {
var l = function (req, resp) {
contentType = contentType || 'text/plain'
resp.writeHead(200, {'content-type':contentType})
resp.write(text)
resp.end()
}
return l;
}
exports.createChunkResponse = function (chunks, contentType) {
var l = function (req, resp) {
contentType = contentType || 'text/plain'
resp.writeHead(200, {'content-type':contentType})
chunks.forEach(function (chunk) {
resp.write(chunk)
})
resp.end()
}
return l;
}

77
test/node_modules/request/tests/squid.conf generated vendored Normal file
View File

@@ -0,0 +1,77 @@
#
# Recommended minimum configuration:
#
acl manager proto cache_object
acl localhost src 127.0.0.1/32 ::1
acl to_localhost dst 127.0.0.0/8 0.0.0.0/32 ::1
# Example rule allowing access from your local networks.
# Adapt to list your (internal) IP networks from where browsing
# should be allowed
acl localnet src 10.0.0.0/8 # RFC1918 possible internal network
acl localnet src 172.16.0.0/12 # RFC1918 possible internal network
acl localnet src 192.168.0.0/16 # RFC1918 possible internal network
acl localnet src fc00::/7 # RFC 4193 local private network range
acl localnet src fe80::/10 # RFC 4291 link-local (directly plugged) machines
acl SSL_ports port 443
acl Safe_ports port 80 # http
acl Safe_ports port 21 # ftp
acl Safe_ports port 443 # https
acl Safe_ports port 70 # gopher
acl Safe_ports port 210 # wais
acl Safe_ports port 1025-65535 # unregistered ports
acl Safe_ports port 280 # http-mgmt
acl Safe_ports port 488 # gss-http
acl Safe_ports port 591 # filemaker
acl Safe_ports port 777 # multiling http
acl CONNECT method CONNECT
#
# Recommended minimum Access Permission configuration:
#
# Only allow cachemgr access from localhost
http_access allow manager localhost
http_access deny manager
# Deny requests to certain unsafe ports
http_access deny !Safe_ports
# Deny CONNECT to other than secure SSL ports
#http_access deny CONNECT !SSL_ports
# We strongly recommend the following be uncommented to protect innocent
# web applications running on the proxy server who think the only
# one who can access services on "localhost" is a local user
#http_access deny to_localhost
#
# INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS
#
# Example rule allowing access from your local networks.
# Adapt localnet in the ACL section to list your (internal) IP networks
# from where browsing should be allowed
http_access allow localnet
http_access allow localhost
# And finally deny all other access to this proxy
http_access deny all
# Squid normally listens to port 3128
http_port 3128
# We recommend you to use at least the following line.
hierarchy_stoplist cgi-bin ?
# Uncomment and adjust the following to add a disk cache directory.
#cache_dir ufs /usr/local/var/cache 100 16 256
# Leave coredumps in the first cache dir
coredump_dir /usr/local/var/cache
# Add any of your own refresh_pattern entries above these.
refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern -i (/cgi-bin/|\?) 0 0% 0
refresh_pattern . 0 20% 4320

20
test/node_modules/request/tests/ssl/ca/ca.cnf generated vendored Normal file
View File

@@ -0,0 +1,20 @@
[ req ]
default_bits = 1024
days = 3650
distinguished_name = req_distinguished_name
attributes = req_attributes
prompt = no
output_password = password
[ req_distinguished_name ]
C = US
ST = CA
L = Oakland
O = request
OU = request Certificate Authority
CN = requestCA
emailAddress = mikeal@mikealrogers.com
[ req_attributes ]
challengePassword = password challenge

0
test/node_modules/request/tests/ssl/ca/ca.crl generated vendored Normal file
View File

17
test/node_modules/request/tests/ssl/ca/ca.crt generated vendored Normal file
View File

@@ -0,0 +1,17 @@
-----BEGIN CERTIFICATE-----
MIICvTCCAiYCCQDn+P/MSbDsWjANBgkqhkiG9w0BAQUFADCBojELMAkGA1UEBhMC
VVMxCzAJBgNVBAgTAkNBMRAwDgYDVQQHEwdPYWtsYW5kMRAwDgYDVQQKEwdyZXF1
ZXN0MSYwJAYDVQQLEx1yZXF1ZXN0IENlcnRpZmljYXRlIEF1dGhvcml0eTESMBAG
A1UEAxMJcmVxdWVzdENBMSYwJAYJKoZIhvcNAQkBFhdtaWtlYWxAbWlrZWFscm9n
ZXJzLmNvbTAeFw0xMjAzMDEyMjUwNTZaFw0yMjAyMjcyMjUwNTZaMIGiMQswCQYD
VQQGEwJVUzELMAkGA1UECBMCQ0ExEDAOBgNVBAcTB09ha2xhbmQxEDAOBgNVBAoT
B3JlcXVlc3QxJjAkBgNVBAsTHXJlcXVlc3QgQ2VydGlmaWNhdGUgQXV0aG9yaXR5
MRIwEAYDVQQDEwlyZXF1ZXN0Q0ExJjAkBgkqhkiG9w0BCQEWF21pa2VhbEBtaWtl
YWxyb2dlcnMuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC7t9pQUAK4
5XJYTI6NrF0n3G2HZsfN+rPYSVzzL8SuVyb1tHXos+vbPm3NKI4E8X1yVAXU8CjJ
5SqXnp4DAypAhaseho81cbhk7LXUhFz78OvAa+OD+xTAEAnNQ8tGUr4VGyplEjfD
xsBVuqV2j8GPNTftr+drOCFlqfAgMrBn4wIDAQABMA0GCSqGSIb3DQEBBQUAA4GB
ADVdTlVAL45R+PACNS7Gs4o81CwSclukBu4FJbxrkd4xGQmurgfRrYYKjtqiopQm
D7ysRamS3HMN9/VKq2T7r3z1PMHPAy7zM4uoXbbaTKwlnX4j/8pGPn8Ca3qHXYlo
88L/OOPc6Di7i7qckS3HFbXQCTiULtxWmy97oEuTwrAj
-----END CERTIFICATE-----

13
test/node_modules/request/tests/ssl/ca/ca.csr generated vendored Normal file
View File

@@ -0,0 +1,13 @@
-----BEGIN CERTIFICATE REQUEST-----
MIICBjCCAW8CAQAwgaIxCzAJBgNVBAYTAlVTMQswCQYDVQQIEwJDQTEQMA4GA1UE
BxMHT2FrbGFuZDEQMA4GA1UEChMHcmVxdWVzdDEmMCQGA1UECxMdcmVxdWVzdCBD
ZXJ0aWZpY2F0ZSBBdXRob3JpdHkxEjAQBgNVBAMTCXJlcXVlc3RDQTEmMCQGCSqG
SIb3DQEJARYXbWlrZWFsQG1pa2VhbHJvZ2Vycy5jb20wgZ8wDQYJKoZIhvcNAQEB
BQADgY0AMIGJAoGBALu32lBQArjlclhMjo2sXSfcbYdmx836s9hJXPMvxK5XJvW0
deiz69s+bc0ojgTxfXJUBdTwKMnlKpeengMDKkCFqx6GjzVxuGTstdSEXPvw68Br
44P7FMAQCc1Dy0ZSvhUbKmUSN8PGwFW6pXaPwY81N+2v52s4IWWp8CAysGfjAgMB
AAGgIzAhBgkqhkiG9w0BCQcxFBMScGFzc3dvcmQgY2hhbGxlbmdlMA0GCSqGSIb3
DQEBBQUAA4GBAGJO7grHeVHXetjHEK8urIxdnvfB2qeZeObz4GPKIkqUurjr0rfj
bA3EK1kDMR5aeQWR8RunixdM16Q6Ry0lEdLVWkdSwRN9dmirIHT9cypqnD/FYOia
SdezZ0lUzXgmJIwRYRwB1KSMMocIf52ll/xC2bEGg7/ZAEuAyAgcZV3X
-----END CERTIFICATE REQUEST-----

18
test/node_modules/request/tests/ssl/ca/ca.key generated vendored Normal file
View File

@@ -0,0 +1,18 @@
-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: DES-EDE3-CBC,C8B5887048377F02
nyD5ZH0Wup2uWsDvurq5mKDaDrf8lvNn9w0SH/ZkVnfR1/bkwqrFriqJWvZNUG+q
nS0iBYczsWLJnbub9a1zLOTENWUKVD5uqbC3aGHhnoUTNSa27DONgP8gHOn6JgR+
GAKo01HCSTiVT4LjkwN337QKHnMP2fTzg+IoC/CigvMcq09hRLwU1/guq0GJKGwH
gTxYNuYmQC4Tjh8vdS4liF+Ve/P3qPR2CehZrIOkDT8PHJBGQJRo4xGUIB7Tpk38
VCk+UZ0JCS2coY8VkY/9tqFJp/ZnnQQVmaNbdRqg7ECKL+bXnNo7yjzmazPZmPe3
/ShbE0+CTt7LrjCaQAxWbeDzqfo1lQfgN1LulTm8MCXpQaJpv7v1VhIhQ7afjMYb
4thW/ypHPiYS2YJCAkAVlua9Oxzzh1qJoh8Df19iHtpd79Q77X/qf+1JvITlMu0U
gi7yEatmQcmYNws1mtTC1q2DXrO90c+NZ0LK/Alse6NRL/xiUdjug2iHeTf/idOR
Gg/5dSZbnnlj1E5zjSMDkzg6EHAFmHV4jYGSAFLEQgp4V3ZhMVoWZrvvSHgKV/Qh
FqrAK4INr1G2+/QTd09AIRzfy3/j6yD4A9iNaOsEf9Ua7Qh6RcALRCAZTWR5QtEf
dX+iSNJ4E85qXs0PqwkMDkoaxIJ+tmIRJY7y8oeylV8cfGAi8Soubt/i3SlR8IHC
uDMas/2OnwafK3N7ODeE1i7r7wkzQkSHaEz0TrF8XRnP25jAICCSLiMdAAjKfxVb
EvzsFSuAy3Jt6bU3hSLY9o4YVYKE+68ITMv9yNjvTsEiW+T+IbN34w==
-----END RSA PRIVATE KEY-----

1
test/node_modules/request/tests/ssl/ca/ca.srl generated vendored Normal file
View File

@@ -0,0 +1 @@
ADF62016AA40C9C3

19
test/node_modules/request/tests/ssl/ca/server.cnf generated vendored Normal file
View File

@@ -0,0 +1,19 @@
[ req ]
default_bits = 1024
days = 3650
distinguished_name = req_distinguished_name
attributes = req_attributes
prompt = no
[ req_distinguished_name ]
C = US
ST = CA
L = Oakland
O = request
OU = testing
CN = testing.request.mikealrogers.com
emailAddress = mikeal@mikealrogers.com
[ req_attributes ]
challengePassword = password challenge

16
test/node_modules/request/tests/ssl/ca/server.crt generated vendored Normal file
View File

@@ -0,0 +1,16 @@
-----BEGIN CERTIFICATE-----
MIICejCCAeMCCQCt9iAWqkDJwzANBgkqhkiG9w0BAQUFADCBojELMAkGA1UEBhMC
VVMxCzAJBgNVBAgTAkNBMRAwDgYDVQQHEwdPYWtsYW5kMRAwDgYDVQQKEwdyZXF1
ZXN0MSYwJAYDVQQLEx1yZXF1ZXN0IENlcnRpZmljYXRlIEF1dGhvcml0eTESMBAG
A1UEAxMJcmVxdWVzdENBMSYwJAYJKoZIhvcNAQkBFhdtaWtlYWxAbWlrZWFscm9n
ZXJzLmNvbTAeFw0xMjAzMDEyMjUwNTZaFw0yMjAyMjcyMjUwNTZaMIGjMQswCQYD
VQQGEwJVUzELMAkGA1UECBMCQ0ExEDAOBgNVBAcTB09ha2xhbmQxEDAOBgNVBAoT
B3JlcXVlc3QxEDAOBgNVBAsTB3Rlc3RpbmcxKTAnBgNVBAMTIHRlc3RpbmcucmVx
dWVzdC5taWtlYWxyb2dlcnMuY29tMSYwJAYJKoZIhvcNAQkBFhdtaWtlYWxAbWlr
ZWFscm9nZXJzLmNvbTBcMA0GCSqGSIb3DQEBAQUAA0sAMEgCQQDgVl0jMumvOpmM
20W5v9yhGgZj8hPhEQF/N7yCBVBn/rWGYm70IHC8T/pR5c0LkWc5gdnCJEvKWQjh
DBKxZD8FAgMBAAEwDQYJKoZIhvcNAQEFBQADgYEABShRkNgFbgs4vUWW9R9deNJj
7HJoiTmvkmoOC7QzcYkjdgHbOxsSq3rBnwxsVjY9PAtPwBn0GRspOeG7KzKRgySB
kb22LyrCFKbEOfKO/+CJc80ioK9zEPVjGsFMyAB+ftYRqM+s/4cQlTg/m89l01wC
yapjN3RxZbInGhWR+jA=
-----END CERTIFICATE-----

11
test/node_modules/request/tests/ssl/ca/server.csr generated vendored Normal file
View File

@@ -0,0 +1,11 @@
-----BEGIN CERTIFICATE REQUEST-----
MIIBgjCCASwCAQAwgaMxCzAJBgNVBAYTAlVTMQswCQYDVQQIEwJDQTEQMA4GA1UE
BxMHT2FrbGFuZDEQMA4GA1UEChMHcmVxdWVzdDEQMA4GA1UECxMHdGVzdGluZzEp
MCcGA1UEAxMgdGVzdGluZy5yZXF1ZXN0Lm1pa2VhbHJvZ2Vycy5jb20xJjAkBgkq
hkiG9w0BCQEWF21pa2VhbEBtaWtlYWxyb2dlcnMuY29tMFwwDQYJKoZIhvcNAQEB
BQADSwAwSAJBAOBWXSMy6a86mYzbRbm/3KEaBmPyE+ERAX83vIIFUGf+tYZibvQg
cLxP+lHlzQuRZzmB2cIkS8pZCOEMErFkPwUCAwEAAaAjMCEGCSqGSIb3DQEJBzEU
ExJwYXNzd29yZCBjaGFsbGVuZ2UwDQYJKoZIhvcNAQEFBQADQQBD3E5WekQzCEJw
7yOcqvtPYIxGaX8gRKkYfLPoj3pm3GF5SGqtJKhylKfi89szHXgktnQgzff9FN+A
HidVJ/3u
-----END CERTIFICATE REQUEST-----

28
test/node_modules/request/tests/ssl/ca/server.js generated vendored Normal file
View File

@@ -0,0 +1,28 @@
var fs = require("fs")
var https = require("https")
var options = { key: fs.readFileSync("./server.key")
, cert: fs.readFileSync("./server.crt") }
var server = https.createServer(options, function (req, res) {
res.writeHead(200)
res.end()
server.close()
})
server.listen(1337)
var ca = fs.readFileSync("./ca.crt")
var agent = new https.Agent({ host: "localhost", port: 1337, ca: ca })
https.request({ host: "localhost"
, method: "HEAD"
, port: 1337
, headers: { host: "testing.request.mikealrogers.com" }
, agent: agent
, ca: [ ca ]
, path: "/" }, function (res) {
if (res.client.authorized) {
console.log("node test: OK")
} else {
throw new Error(res.client.authorizationError)
}
}).end()

9
test/node_modules/request/tests/ssl/ca/server.key generated vendored Normal file
View File

@@ -0,0 +1,9 @@
-----BEGIN RSA PRIVATE KEY-----
MIIBOwIBAAJBAOBWXSMy6a86mYzbRbm/3KEaBmPyE+ERAX83vIIFUGf+tYZibvQg
cLxP+lHlzQuRZzmB2cIkS8pZCOEMErFkPwUCAwEAAQJAK+r8ZM2sze8s7FRo/ApB
iRBtO9fCaIdJwbwJnXKo4RKwZDt1l2mm+fzZ+/QaQNjY1oTROkIIXmnwRvZWfYlW
gQIhAPKYsG+YSBN9o8Sdp1DMyZ/rUifKX3OE6q9tINkgajDVAiEA7Ltqh01+cnt0
JEnud/8HHcuehUBLMofeg0G+gCnSbXECIQCqDvkXsWNNLnS/3lgsnvH0Baz4sbeJ
rjIpuVEeg8eM5QIgbu0+9JmOV6ybdmmiMV4yAncoF35R/iKGVHDZCAsQzDECIQDZ
0jGz22tlo5YMcYSqrdD3U4sds1pwiAaWFRbCunoUJw==
-----END RSA PRIVATE KEY-----

16
test/node_modules/request/tests/ssl/npm-ca.crt generated vendored Normal file
View File

@@ -0,0 +1,16 @@
-----BEGIN CERTIFICATE-----
MIIChzCCAfACCQDauvz/KHp8ejANBgkqhkiG9w0BAQUFADCBhzELMAkGA1UEBhMC
VVMxCzAJBgNVBAgTAkNBMRAwDgYDVQQHEwdPYWtsYW5kMQwwCgYDVQQKEwNucG0x
IjAgBgNVBAsTGW5wbSBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkxDjAMBgNVBAMTBW5w
bUNBMRcwFQYJKoZIhvcNAQkBFghpQGl6cy5tZTAeFw0xMTA5MDUwMTQ3MTdaFw0y
MTA5MDIwMTQ3MTdaMIGHMQswCQYDVQQGEwJVUzELMAkGA1UECBMCQ0ExEDAOBgNV
BAcTB09ha2xhbmQxDDAKBgNVBAoTA25wbTEiMCAGA1UECxMZbnBtIENlcnRpZmlj
YXRlIEF1dGhvcml0eTEOMAwGA1UEAxMFbnBtQ0ExFzAVBgkqhkiG9w0BCQEWCGlA
aXpzLm1lMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDLI4tIqPpRW+ACw9GE
OgBlJZwK5f8nnKCLK629Pv5yJpQKs3DENExAyOgDcyaF0HD0zk8zTp+ZsLaNdKOz
Gn2U181KGprGKAXP6DU6ByOJDWmTlY6+Ad1laYT0m64fERSpHw/hjD3D+iX4aMOl
y0HdbT5m1ZGh6SJz3ZqxavhHLQIDAQABMA0GCSqGSIb3DQEBBQUAA4GBAC4ySDbC
l7W1WpLmtLGEQ/yuMLUf6Jy/vr+CRp4h+UzL+IQpCv8FfxsYE7dhf/bmWTEupBkv
yNL18lipt2jSvR3v6oAHAReotvdjqhxddpe5Holns6EQd1/xEZ7sB1YhQKJtvUrl
ZNufy1Jf1r0ldEGeA+0ISck7s+xSh9rQD2Op
-----END CERTIFICATE-----

15
test/node_modules/request/tests/ssl/test.crt generated vendored Normal file
View File

@@ -0,0 +1,15 @@
-----BEGIN CERTIFICATE-----
MIICQzCCAawCCQCO/XWtRFck1jANBgkqhkiG9w0BAQUFADBmMQswCQYDVQQGEwJU
SDEQMA4GA1UECBMHQmFuZ2tvazEOMAwGA1UEBxMFU2lsb20xGzAZBgNVBAoTElRo
ZSBSZXF1ZXN0IE1vZHVsZTEYMBYGA1UEAxMPcmVxdWVzdC5leGFtcGxlMB4XDTEx
MTIwMzAyMjkyM1oXDTIxMTEzMDAyMjkyM1owZjELMAkGA1UEBhMCVEgxEDAOBgNV
BAgTB0Jhbmdrb2sxDjAMBgNVBAcTBVNpbG9tMRswGQYDVQQKExJUaGUgUmVxdWVz
dCBNb2R1bGUxGDAWBgNVBAMTD3JlcXVlc3QuZXhhbXBsZTCBnzANBgkqhkiG9w0B
AQEFAAOBjQAwgYkCgYEAwmctddZqlA48+NXs0yOy92DijcQV1jf87zMiYAIlNUto
wghVbTWgJU5r0pdKrD16AptnWJTzKanhItEX8XCCPgsNkq1afgTtJP7rNkwu3xcj
eIMkhJg/ay4ZnkbnhYdsii5VTU5prix6AqWRAhbkBgoA+iVyHyof8wvZyKBoFTMC
AwEAATANBgkqhkiG9w0BAQUFAAOBgQB6BybMJbpeiABgihDfEVBcAjDoQ8gUMgwV
l4NulugfKTDmArqnR9aPd4ET5jX5dkMP4bwCHYsvrcYDeWEQy7x5WWuylOdKhua4
L4cEi2uDCjqEErIG3cc1MCOk6Cl6Ld6tkIzQSf953qfdEACRytOeUqLNQcrXrqeE
c7U8F6MWLQ==
-----END CERTIFICATE-----

15
test/node_modules/request/tests/ssl/test.key generated vendored Normal file
View File

@@ -0,0 +1,15 @@
-----BEGIN RSA PRIVATE KEY-----
MIICXgIBAAKBgQDCZy111mqUDjz41ezTI7L3YOKNxBXWN/zvMyJgAiU1S2jCCFVt
NaAlTmvSl0qsPXoCm2dYlPMpqeEi0RfxcII+Cw2SrVp+BO0k/us2TC7fFyN4gySE
mD9rLhmeRueFh2yKLlVNTmmuLHoCpZECFuQGCgD6JXIfKh/zC9nIoGgVMwIDAQAB
AoGBALXFwfUf8vHTSmGlrdZS2AGFPvEtuvldyoxi9K5u8xmdFCvxnOcLsF2RsTHt
Mu5QYWhUpNJoG+IGLTPf7RJdj/kNtEs7xXqWy4jR36kt5z5MJzqiK+QIgiO9UFWZ
fjUb6oeDnTIJA9YFBdYi97MDuL89iU/UK3LkJN3hd4rciSbpAkEA+MCkowF5kSFb
rkOTBYBXZfiAG78itDXN6DXmqb9XYY+YBh3BiQM28oxCeQYyFy6pk/nstnd4TXk6
V/ryA2g5NwJBAMgRKTY9KvxJWbESeMEFe2iBIV0c26/72Amgi7ZKUCLukLfD4tLF
+WSZdmTbbqI1079YtwaiOVfiLm45Q/3B0eUCQAaQ/0eWSGE+Yi8tdXoVszjr4GXb
G81qBi91DMu6U1It+jNfIba+MPsiHLcZJMVb4/oWBNukN7bD1nhwFWdlnu0CQQCf
Is9WHkdvz2RxbZDxb8verz/7kXXJQJhx5+rZf7jIYFxqX3yvTNv3wf2jcctJaWlZ
fVZwB193YSivcgt778xlAkEAprYUz3jczjF5r2hrgbizPzPDR94tM5BTO3ki2v3w
kbf+j2g7FNAx6kZiVN8XwfLc8xEeUGiPKwtq3ddPDFh17w==
-----END RSA PRIVATE KEY-----

112
test/node_modules/request/tests/test-body.js generated vendored Normal file
View File

@@ -0,0 +1,112 @@
var server = require('./server')
, events = require('events')
, stream = require('stream')
, assert = require('assert')
, request = require('../main.js')
;
var s = server.createServer();
var tests =
{ testGet :
{ resp : server.createGetResponse("TESTING!")
, expectBody: "TESTING!"
}
, testGetChunkBreak :
{ resp : server.createChunkResponse(
[ new Buffer([239])
, new Buffer([163])
, new Buffer([191])
, new Buffer([206])
, new Buffer([169])
, new Buffer([226])
, new Buffer([152])
, new Buffer([131])
])
, expectBody: "Ω☃"
}
, testGetBuffer :
{ resp : server.createGetResponse(new Buffer("TESTING!"))
, encoding: null
, expectBody: new Buffer("TESTING!")
}
, testGetJSON :
{ resp : server.createGetResponse('{"test":true}', 'application/json')
, json : true
, expectBody: {"test":true}
}
, testPutString :
{ resp : server.createPostValidator("PUTTINGDATA")
, method : "PUT"
, body : "PUTTINGDATA"
}
, testPutBuffer :
{ resp : server.createPostValidator("PUTTINGDATA")
, method : "PUT"
, body : new Buffer("PUTTINGDATA")
}
, testPutJSON :
{ resp : server.createPostValidator(JSON.stringify({foo: 'bar'}))
, method: "PUT"
, json: {foo: 'bar'}
}
, testPutMultipart :
{ resp: server.createPostValidator(
'--__BOUNDARY__\r\n' +
'content-type: text/html\r\n' +
'\r\n' +
'<html><body>Oh hi.</body></html>' +
'\r\n--__BOUNDARY__\r\n\r\n' +
'Oh hi.' +
'\r\n--__BOUNDARY__--'
)
, method: "PUT"
, multipart:
[ {'content-type': 'text/html', 'body': '<html><body>Oh hi.</body></html>'}
, {'body': 'Oh hi.'}
]
}
, testPutMultipartPreambleCRLF :
{ resp: server.createPostValidator(
'\r\n--__BOUNDARY__\r\n' +
'content-type: text/html\r\n' +
'\r\n' +
'<html><body>Oh hi.</body></html>' +
'\r\n--__BOUNDARY__\r\n\r\n' +
'Oh hi.' +
'\r\n--__BOUNDARY__--'
)
, method: "PUT"
, preambleCRLF: true
, multipart:
[ {'content-type': 'text/html', 'body': '<html><body>Oh hi.</body></html>'}
, {'body': 'Oh hi.'}
]
}
}
s.listen(s.port, function () {
var counter = 0
for (i in tests) {
(function () {
var test = tests[i]
s.on('/'+i, test.resp)
test.uri = s.url + '/' + i
request(test, function (err, resp, body) {
if (err) throw err
if (test.expectBody) {
assert.deepEqual(test.expectBody, body)
}
counter = counter - 1;
if (counter === 0) {
console.log(Object.keys(tests).length+" tests passed.")
s.close()
}
})
counter++
})()
}
})

29
test/node_modules/request/tests/test-cookie.js generated vendored Normal file
View File

@@ -0,0 +1,29 @@
var Cookie = require('../vendor/cookie')
, assert = require('assert');
var str = 'Sid="s543qactge.wKE61E01Bs%2BKhzmxrwrnug="; Path=/; httpOnly; Expires=Sat, 04 Dec 2010 23:27:28 GMT';
var cookie = new Cookie(str);
// test .toString()
assert.equal(cookie.toString(), str);
// test .path
assert.equal(cookie.path, '/');
// test .httpOnly
assert.equal(cookie.httpOnly, true);
// test .name
assert.equal(cookie.name, 'Sid');
// test .value
assert.equal(cookie.value, '"s543qactge.wKE61E01Bs%2BKhzmxrwrnug="');
// test .expires
assert.equal(cookie.expires instanceof Date, true);
// test .path default
var cookie = new Cookie('foo=bar', { url: 'http://foo.com/bar' });
assert.equal(cookie.path, '/bar');
console.log('All tests passed');

90
test/node_modules/request/tests/test-cookiejar.js generated vendored Normal file
View File

@@ -0,0 +1,90 @@
var Cookie = require('../vendor/cookie')
, Jar = require('../vendor/cookie/jar')
, assert = require('assert');
function expires(ms) {
return new Date(Date.now() + ms).toUTCString();
}
// test .get() expiration
(function() {
var jar = new Jar;
var cookie = new Cookie('sid=1234; path=/; expires=' + expires(1000));
jar.add(cookie);
setTimeout(function(){
var cookies = jar.get({ url: 'http://foo.com/foo' });
assert.equal(cookies.length, 1);
assert.equal(cookies[0], cookie);
setTimeout(function(){
var cookies = jar.get({ url: 'http://foo.com/foo' });
assert.equal(cookies.length, 0);
}, 1000);
}, 5);
})();
// test .get() path support
(function() {
var jar = new Jar;
var a = new Cookie('sid=1234; path=/');
var b = new Cookie('sid=1111; path=/foo/bar');
var c = new Cookie('sid=2222; path=/');
jar.add(a);
jar.add(b);
jar.add(c);
// should remove the duplicates
assert.equal(jar.cookies.length, 2);
// same name, same path, latter prevails
var cookies = jar.get({ url: 'http://foo.com/' });
assert.equal(cookies.length, 1);
assert.equal(cookies[0], c);
// same name, diff path, path specifity prevails, latter prevails
var cookies = jar.get({ url: 'http://foo.com/foo/bar' });
assert.equal(cookies.length, 1);
assert.equal(cookies[0], b);
var jar = new Jar;
var a = new Cookie('sid=1111; path=/foo/bar');
var b = new Cookie('sid=1234; path=/');
jar.add(a);
jar.add(b);
var cookies = jar.get({ url: 'http://foo.com/foo/bar' });
assert.equal(cookies.length, 1);
assert.equal(cookies[0], a);
var cookies = jar.get({ url: 'http://foo.com/' });
assert.equal(cookies.length, 1);
assert.equal(cookies[0], b);
var jar = new Jar;
var a = new Cookie('sid=1111; path=/foo/bar');
var b = new Cookie('sid=3333; path=/foo/bar');
var c = new Cookie('pid=3333; path=/foo/bar');
var d = new Cookie('sid=2222; path=/foo/');
var e = new Cookie('sid=1234; path=/');
jar.add(a);
jar.add(b);
jar.add(c);
jar.add(d);
jar.add(e);
var cookies = jar.get({ url: 'http://foo.com/foo/bar' });
assert.equal(cookies.length, 2);
assert.equal(cookies[0], b);
assert.equal(cookies[1], c);
var cookies = jar.get({ url: 'http://foo.com/foo/' });
assert.equal(cookies.length, 1);
assert.equal(cookies[0], d);
var cookies = jar.get({ url: 'http://foo.com/' });
assert.equal(cookies.length, 1);
assert.equal(cookies[0], e);
})();
setTimeout(function() {
console.log('All tests passed');
}, 1200);

99
test/node_modules/request/tests/test-defaults.js generated vendored Normal file
View File

@@ -0,0 +1,99 @@
var server = require('./server')
, assert = require('assert')
, request = require('../main.js')
;
var s = server.createServer();
s.listen(s.port, function () {
var counter = 0;
s.on('/get', function (req, resp) {
assert.equal(req.headers.foo, 'bar');
assert.equal(req.method, 'GET')
resp.writeHead(200, {'Content-Type': 'text/plain'});
resp.end('TESTING!');
});
// test get(string, function)
request.defaults({headers:{foo:"bar"}})(s.url + '/get', function (e, r, b){
if (e) throw e;
assert.deepEqual("TESTING!", b);
counter += 1;
});
s.on('/post', function (req, resp) {
assert.equal(req.headers.foo, 'bar');
assert.equal(req.headers['content-type'], 'application/json');
assert.equal(req.method, 'POST')
resp.writeHead(200, {'Content-Type': 'application/json'});
resp.end(JSON.stringify({foo:'bar'}));
});
// test post(string, object, function)
request.defaults({headers:{foo:"bar"}}).post(s.url + '/post', {json: true}, function (e, r, b){
if (e) throw e;
assert.deepEqual('bar', b.foo);
counter += 1;
});
s.on('/del', function (req, resp) {
assert.equal(req.headers.foo, 'bar');
assert.equal(req.method, 'DELETE')
resp.writeHead(200, {'Content-Type': 'application/json'});
resp.end(JSON.stringify({foo:'bar'}));
});
// test .del(string, function)
request.defaults({headers:{foo:"bar"}, json:true}).del(s.url + '/del', function (e, r, b){
if (e) throw e;
assert.deepEqual('bar', b.foo);
counter += 1;
});
s.on('/head', function (req, resp) {
assert.equal(req.headers.foo, 'bar');
assert.equal(req.method, 'HEAD')
resp.writeHead(200, {'Content-Type': 'text/plain'});
resp.end();
});
// test head.(object, function)
request.defaults({headers:{foo:"bar"}}).head({uri: s.url + '/head'}, function (e, r, b){
if (e) throw e;
counter += 1;
});
s.on('/get_custom', function(req, resp) {
assert.equal(req.headers.foo, 'bar');
assert.equal(req.headers.x, 'y');
resp.writeHead(200, {'Content-Type': 'text/plain'});
resp.end();
});
// test custom request handler function
var defaultRequest = request.defaults({
headers:{foo:"bar"}
, body: 'TESTING!'
}, function(uri, options, callback) {
var params = request.initParams(uri, options, callback);
options = params.options;
options.headers.x = 'y';
return request(params.uri, params.options, params.callback);
});
var msg = 'defaults test failed. head request should throw earlier';
assert.throws(function() {
defaultRequest.head(s.url + '/get_custom', function(e, r, b) {
throw new Error(msg);
});
counter+=1;
}, msg);
defaultRequest.get(s.url + '/get_custom', function(e, r, b) {
if(e) throw e;
counter += 1;
console.log(counter.toString() + " tests passed.");
s.close();
});
})

37
test/node_modules/request/tests/test-errors.js generated vendored Normal file
View File

@@ -0,0 +1,37 @@
var server = require('./server')
, events = require('events')
, assert = require('assert')
, request = require('../main.js')
;
var local = 'http://localhost:8888/asdf'
try {
request({uri:local, body:{}})
assert.fail("Should have throw")
} catch(e) {
assert.equal(e.message, 'Argument error, options.body.')
}
try {
request({uri:local, multipart: 'foo'})
assert.fail("Should have throw")
} catch(e) {
assert.equal(e.message, 'Argument error, options.multipart.')
}
try {
request({uri:local, multipart: [{}]})
assert.fail("Should have throw")
} catch(e) {
assert.equal(e.message, 'Body attribute missing in multipart.')
}
try {
request(local, {multipart: [{}]})
assert.fail("Should have throw")
} catch(e) {
assert.equal(e.message, 'Body attribute missing in multipart.')
}
console.log("All tests passed.")

52
test/node_modules/request/tests/test-headers.js generated vendored Normal file
View File

@@ -0,0 +1,52 @@
var server = require('./server')
, assert = require('assert')
, request = require('../main.js')
, Cookie = require('../vendor/cookie')
, Jar = require('../vendor/cookie/jar')
, s = server.createServer()
s.listen(s.port, function () {
var serverUri = 'http://localhost:' + s.port
, numTests = 0
, numOutstandingTests = 0
function createTest(requestObj, serverAssertFn) {
var testNumber = numTests;
numTests += 1;
numOutstandingTests += 1;
s.on('/' + testNumber, function (req, res) {
serverAssertFn(req, res);
res.writeHead(200);
res.end();
});
requestObj.url = serverUri + '/' + testNumber
request(requestObj, function (err, res, body) {
assert.ok(!err)
assert.equal(res.statusCode, 200)
numOutstandingTests -= 1
if (numOutstandingTests === 0) {
console.log(numTests + ' tests passed.')
s.close()
}
})
}
// Issue #125: headers.cookie shouldn't be replaced when a cookie jar isn't specified
createTest({headers: {cookie: 'foo=bar'}}, function (req, res) {
assert.ok(req.headers.cookie)
assert.equal(req.headers.cookie, 'foo=bar')
})
// Issue #125: headers.cookie + cookie jar
var jar = new Jar()
jar.add(new Cookie('quux=baz'));
createTest({jar: jar, headers: {cookie: 'foo=bar'}}, function (req, res) {
assert.ok(req.headers.cookie)
assert.equal(req.headers.cookie, 'foo=bar; quux=baz')
})
// There should be no cookie header when neither headers.cookie nor a cookie jar is specified
createTest({}, function (req, res) {
assert.ok(!req.headers.cookie)
})
})

94
test/node_modules/request/tests/test-httpModule.js generated vendored Normal file
View File

@@ -0,0 +1,94 @@
var http = require('http')
, https = require('https')
, server = require('./server')
, assert = require('assert')
, request = require('../main.js')
var faux_requests_made = {'http':0, 'https':0}
function wrap_request(name, module) {
// Just like the http or https module, but note when a request is made.
var wrapped = {}
Object.keys(module).forEach(function(key) {
var value = module[key];
if(key != 'request')
wrapped[key] = value;
else
wrapped[key] = function(options, callback) {
faux_requests_made[name] += 1
return value.apply(this, arguments)
}
})
return wrapped;
}
var faux_http = wrap_request('http', http)
, faux_https = wrap_request('https', https)
, plain_server = server.createServer()
, https_server = server.createSSLServer()
plain_server.listen(plain_server.port, function() {
plain_server.on('/plain', function (req, res) {
res.writeHead(200)
res.end('plain')
})
plain_server.on('/to_https', function (req, res) {
res.writeHead(301, {'location':'https://localhost:'+https_server.port + '/https'})
res.end()
})
https_server.listen(https_server.port, function() {
https_server.on('/https', function (req, res) {
res.writeHead(200)
res.end('https')
})
https_server.on('/to_plain', function (req, res) {
res.writeHead(302, {'location':'http://localhost:'+plain_server.port + '/plain'})
res.end()
})
run_tests()
run_tests({})
run_tests({'http:':faux_http})
run_tests({'https:':faux_https})
run_tests({'http:':faux_http, 'https:':faux_https})
})
})
function run_tests(httpModules) {
var to_https = 'http://localhost:'+plain_server.port+'/to_https'
var to_plain = 'https://localhost:'+https_server.port+'/to_plain'
request(to_https, {'httpModules':httpModules}, function (er, res, body) {
assert.ok(!er, 'Bounce to SSL worked')
assert.equal(body, 'https', 'Received HTTPS server body')
done()
})
request(to_plain, {'httpModules':httpModules}, function (er, res, body) {
assert.ok(!er, 'Bounce to plaintext server worked')
assert.equal(body, 'plain', 'Received HTTPS server body')
done()
})
}
var passed = 0;
function done() {
passed += 1
var expected = 10
if(passed == expected) {
plain_server.close()
https_server.close()
assert.equal(faux_requests_made.http, 4, 'Wrapped http module called appropriately')
assert.equal(faux_requests_made.https, 4, 'Wrapped https module called appropriately')
console.log((expected+2) + ' tests passed.')
}
}

97
test/node_modules/request/tests/test-https-strict.js generated vendored Normal file
View File

@@ -0,0 +1,97 @@
// a test where we validate the siguature of the keys
// otherwise exactly the same as the ssl test
var server = require('./server')
, assert = require('assert')
, request = require('../main.js')
, fs = require('fs')
, path = require('path')
, opts = { key: path.resolve(__dirname, 'ssl/ca/server.key')
, cert: path.resolve(__dirname, 'ssl/ca/server.crt') }
, s = server.createSSLServer(null, opts)
, caFile = path.resolve(__dirname, 'ssl/ca/ca.crt')
, ca = fs.readFileSync(caFile)
var tests =
{ testGet :
{ resp : server.createGetResponse("TESTING!")
, expectBody: "TESTING!"
}
, testGetChunkBreak :
{ resp : server.createChunkResponse(
[ new Buffer([239])
, new Buffer([163])
, new Buffer([191])
, new Buffer([206])
, new Buffer([169])
, new Buffer([226])
, new Buffer([152])
, new Buffer([131])
])
, expectBody: "Ω☃"
}
, testGetJSON :
{ resp : server.createGetResponse('{"test":true}', 'application/json')
, json : true
, expectBody: {"test":true}
}
, testPutString :
{ resp : server.createPostValidator("PUTTINGDATA")
, method : "PUT"
, body : "PUTTINGDATA"
}
, testPutBuffer :
{ resp : server.createPostValidator("PUTTINGDATA")
, method : "PUT"
, body : new Buffer("PUTTINGDATA")
}
, testPutJSON :
{ resp : server.createPostValidator(JSON.stringify({foo: 'bar'}))
, method: "PUT"
, json: {foo: 'bar'}
}
, testPutMultipart :
{ resp: server.createPostValidator(
'--__BOUNDARY__\r\n' +
'content-type: text/html\r\n' +
'\r\n' +
'<html><body>Oh hi.</body></html>' +
'\r\n--__BOUNDARY__\r\n\r\n' +
'Oh hi.' +
'\r\n--__BOUNDARY__--'
)
, method: "PUT"
, multipart:
[ {'content-type': 'text/html', 'body': '<html><body>Oh hi.</body></html>'}
, {'body': 'Oh hi.'}
]
}
}
s.listen(s.port, function () {
var counter = 0
for (i in tests) {
(function () {
var test = tests[i]
s.on('/'+i, test.resp)
test.uri = s.url + '/' + i
test.strictSSL = true
test.ca = ca
test.headers = { host: 'testing.request.mikealrogers.com' }
request(test, function (err, resp, body) {
if (err) throw err
if (test.expectBody) {
assert.deepEqual(test.expectBody, body)
}
counter = counter - 1;
if (counter === 0) {
console.log(Object.keys(tests).length+" tests passed.")
s.close()
}
})
counter++
})()
}
})

86
test/node_modules/request/tests/test-https.js generated vendored Normal file
View File

@@ -0,0 +1,86 @@
var server = require('./server')
, assert = require('assert')
, request = require('../main.js')
var s = server.createSSLServer();
var tests =
{ testGet :
{ resp : server.createGetResponse("TESTING!")
, expectBody: "TESTING!"
}
, testGetChunkBreak :
{ resp : server.createChunkResponse(
[ new Buffer([239])
, new Buffer([163])
, new Buffer([191])
, new Buffer([206])
, new Buffer([169])
, new Buffer([226])
, new Buffer([152])
, new Buffer([131])
])
, expectBody: "Ω☃"
}
, testGetJSON :
{ resp : server.createGetResponse('{"test":true}', 'application/json')
, json : true
, expectBody: {"test":true}
}
, testPutString :
{ resp : server.createPostValidator("PUTTINGDATA")
, method : "PUT"
, body : "PUTTINGDATA"
}
, testPutBuffer :
{ resp : server.createPostValidator("PUTTINGDATA")
, method : "PUT"
, body : new Buffer("PUTTINGDATA")
}
, testPutJSON :
{ resp : server.createPostValidator(JSON.stringify({foo: 'bar'}))
, method: "PUT"
, json: {foo: 'bar'}
}
, testPutMultipart :
{ resp: server.createPostValidator(
'--__BOUNDARY__\r\n' +
'content-type: text/html\r\n' +
'\r\n' +
'<html><body>Oh hi.</body></html>' +
'\r\n--__BOUNDARY__\r\n\r\n' +
'Oh hi.' +
'\r\n--__BOUNDARY__--'
)
, method: "PUT"
, multipart:
[ {'content-type': 'text/html', 'body': '<html><body>Oh hi.</body></html>'}
, {'body': 'Oh hi.'}
]
}
}
s.listen(s.port, function () {
var counter = 0
for (i in tests) {
(function () {
var test = tests[i]
s.on('/'+i, test.resp)
test.uri = s.url + '/' + i
request(test, function (err, resp, body) {
if (err) throw err
if (test.expectBody) {
assert.deepEqual(test.expectBody, body)
}
counter = counter - 1;
if (counter === 0) {
console.log(Object.keys(tests).length+" tests passed.")
s.close()
}
})
counter++
})()
}
})

117
test/node_modules/request/tests/test-oauth.js generated vendored Normal file
View File

@@ -0,0 +1,117 @@
var hmacsign = require('../oauth').hmacsign
, assert = require('assert')
, qs = require('querystring')
, request = require('../main')
;
function getsignature (r) {
var sign
r.headers.Authorization.slice('OAuth '.length).replace(/,\ /g, ',').split(',').forEach(function (v) {
if (v.slice(0, 'oauth_signature="'.length) === 'oauth_signature="') sign = v.slice('oauth_signature="'.length, -1)
})
return decodeURIComponent(sign)
}
// Tests from Twitter documentation https://dev.twitter.com/docs/auth/oauth
var reqsign = hmacsign('POST', 'https://api.twitter.com/oauth/request_token',
{ oauth_callback: 'http://localhost:3005/the_dance/process_callback?service_provider_id=11'
, oauth_consumer_key: 'GDdmIQH6jhtmLUypg82g'
, oauth_nonce: 'QP70eNmVz8jvdPevU3oJD2AfF7R7odC2XJcn4XlZJqk'
, oauth_signature_method: 'HMAC-SHA1'
, oauth_timestamp: '1272323042'
, oauth_version: '1.0'
}, "MCD8BKwGdgPHvAuvgvz4EQpqDAtx89grbuNMRd7Eh98")
console.log(reqsign)
console.log('8wUi7m5HFQy76nowoCThusfgB+Q=')
assert.equal(reqsign, '8wUi7m5HFQy76nowoCThusfgB+Q=')
var accsign = hmacsign('POST', 'https://api.twitter.com/oauth/access_token',
{ oauth_consumer_key: 'GDdmIQH6jhtmLUypg82g'
, oauth_nonce: '9zWH6qe0qG7Lc1telCn7FhUbLyVdjEaL3MO5uHxn8'
, oauth_signature_method: 'HMAC-SHA1'
, oauth_token: '8ldIZyxQeVrFZXFOZH5tAwj6vzJYuLQpl0WUEYtWc'
, oauth_timestamp: '1272323047'
, oauth_verifier: 'pDNg57prOHapMbhv25RNf75lVRd6JDsni1AJJIDYoTY'
, oauth_version: '1.0'
}, "MCD8BKwGdgPHvAuvgvz4EQpqDAtx89grbuNMRd7Eh98", "x6qpRnlEmW9JbQn4PQVVeVG8ZLPEx6A0TOebgwcuA")
console.log(accsign)
console.log('PUw/dHA4fnlJYM6RhXk5IU/0fCc=')
assert.equal(accsign, 'PUw/dHA4fnlJYM6RhXk5IU/0fCc=')
var upsign = hmacsign('POST', 'http://api.twitter.com/1/statuses/update.json',
{ oauth_consumer_key: "GDdmIQH6jhtmLUypg82g"
, oauth_nonce: "oElnnMTQIZvqvlfXM56aBLAf5noGD0AQR3Fmi7Q6Y"
, oauth_signature_method: "HMAC-SHA1"
, oauth_token: "819797-Jxq8aYUDRmykzVKrgoLhXSq67TEa5ruc4GJC2rWimw"
, oauth_timestamp: "1272325550"
, oauth_version: "1.0"
, status: 'setting up my twitter 私のさえずりを設定する'
}, "MCD8BKwGdgPHvAuvgvz4EQpqDAtx89grbuNMRd7Eh98", "J6zix3FfA9LofH0awS24M3HcBYXO5nI1iYe8EfBA")
console.log(upsign)
console.log('yOahq5m0YjDDjfjxHaXEsW9D+X0=')
assert.equal(upsign, 'yOahq5m0YjDDjfjxHaXEsW9D+X0=')
var rsign = request.post(
{ url: 'https://api.twitter.com/oauth/request_token'
, oauth:
{ callback: 'http://localhost:3005/the_dance/process_callback?service_provider_id=11'
, consumer_key: 'GDdmIQH6jhtmLUypg82g'
, nonce: 'QP70eNmVz8jvdPevU3oJD2AfF7R7odC2XJcn4XlZJqk'
, timestamp: '1272323042'
, version: '1.0'
, consumer_secret: "MCD8BKwGdgPHvAuvgvz4EQpqDAtx89grbuNMRd7Eh98"
}
})
setTimeout(function () {
console.log(getsignature(rsign))
assert.equal(reqsign, getsignature(rsign))
})
var raccsign = request.post(
{ url: 'https://api.twitter.com/oauth/access_token'
, oauth:
{ consumer_key: 'GDdmIQH6jhtmLUypg82g'
, nonce: '9zWH6qe0qG7Lc1telCn7FhUbLyVdjEaL3MO5uHxn8'
, signature_method: 'HMAC-SHA1'
, token: '8ldIZyxQeVrFZXFOZH5tAwj6vzJYuLQpl0WUEYtWc'
, timestamp: '1272323047'
, verifier: 'pDNg57prOHapMbhv25RNf75lVRd6JDsni1AJJIDYoTY'
, version: '1.0'
, consumer_secret: "MCD8BKwGdgPHvAuvgvz4EQpqDAtx89grbuNMRd7Eh98"
, token_secret: "x6qpRnlEmW9JbQn4PQVVeVG8ZLPEx6A0TOebgwcuA"
}
})
setTimeout(function () {
console.log(getsignature(raccsign))
assert.equal(accsign, getsignature(raccsign))
}, 1)
var rupsign = request.post(
{ url: 'http://api.twitter.com/1/statuses/update.json'
, oauth:
{ consumer_key: "GDdmIQH6jhtmLUypg82g"
, nonce: "oElnnMTQIZvqvlfXM56aBLAf5noGD0AQR3Fmi7Q6Y"
, signature_method: "HMAC-SHA1"
, token: "819797-Jxq8aYUDRmykzVKrgoLhXSq67TEa5ruc4GJC2rWimw"
, timestamp: "1272325550"
, version: "1.0"
, consumer_secret: "MCD8BKwGdgPHvAuvgvz4EQpqDAtx89grbuNMRd7Eh98"
, token_secret: "J6zix3FfA9LofH0awS24M3HcBYXO5nI1iYe8EfBA"
}
, form: {status: 'setting up my twitter 私のさえずりを設定する'}
})
setTimeout(function () {
console.log(getsignature(rupsign))
assert.equal(upsign, getsignature(rupsign))
}, 1)

92
test/node_modules/request/tests/test-params.js generated vendored Normal file
View File

@@ -0,0 +1,92 @@
var server = require('./server')
, assert = require('assert')
, request = require('../main.js')
;
var s = server.createServer();
var tests =
{ testGet :
{ resp : server.createGetResponse("TESTING!")
, expectBody: "TESTING!"
}
, testGetChunkBreak :
{ resp : server.createChunkResponse(
[ new Buffer([239])
, new Buffer([163])
, new Buffer([191])
, new Buffer([206])
, new Buffer([169])
, new Buffer([226])
, new Buffer([152])
, new Buffer([131])
])
, expectBody: "Ω☃"
}
, testGetBuffer :
{ resp : server.createGetResponse(new Buffer("TESTING!"))
, encoding: null
, expectBody: new Buffer("TESTING!")
}
, testGetJSON :
{ resp : server.createGetResponse('{"test":true}', 'application/json')
, json : true
, expectBody: {"test":true}
}
, testPutString :
{ resp : server.createPostValidator("PUTTINGDATA")
, method : "PUT"
, body : "PUTTINGDATA"
}
, testPutBuffer :
{ resp : server.createPostValidator("PUTTINGDATA")
, method : "PUT"
, body : new Buffer("PUTTINGDATA")
}
, testPutJSON :
{ resp : server.createPostValidator(JSON.stringify({foo: 'bar'}))
, method: "PUT"
, json: {foo: 'bar'}
}
, testPutMultipart :
{ resp: server.createPostValidator(
'--__BOUNDARY__\r\n' +
'content-type: text/html\r\n' +
'\r\n' +
'<html><body>Oh hi.</body></html>' +
'\r\n--__BOUNDARY__\r\n\r\n' +
'Oh hi.' +
'\r\n--__BOUNDARY__--'
)
, method: "PUT"
, multipart:
[ {'content-type': 'text/html', 'body': '<html><body>Oh hi.</body></html>'}
, {'body': 'Oh hi.'}
]
}
}
s.listen(s.port, function () {
var counter = 0
for (i in tests) {
(function () {
var test = tests[i]
s.on('/'+i, test.resp)
//test.uri = s.url + '/' + i
request(s.url + '/' + i, test, function (err, resp, body) {
if (err) throw err
if (test.expectBody) {
assert.deepEqual(test.expectBody, body)
}
counter = counter - 1;
if (counter === 0) {
console.log(Object.keys(tests).length+" tests passed.")
s.close()
}
})
counter++
})()
}
})

202
test/node_modules/request/tests/test-pipes.js generated vendored Normal file
View File

@@ -0,0 +1,202 @@
var server = require('./server')
, events = require('events')
, stream = require('stream')
, assert = require('assert')
, fs = require('fs')
, request = require('../main.js')
, path = require('path')
, util = require('util')
;
var s = server.createServer(3453);
function ValidationStream(str) {
this.str = str
this.buf = ''
this.on('data', function (data) {
this.buf += data
})
this.on('end', function () {
assert.equal(this.str, this.buf)
})
this.writable = true
}
util.inherits(ValidationStream, stream.Stream)
ValidationStream.prototype.write = function (chunk) {
this.emit('data', chunk)
}
ValidationStream.prototype.end = function (chunk) {
if (chunk) emit('data', chunk)
this.emit('end')
}
s.listen(s.port, function () {
counter = 0;
var check = function () {
counter = counter - 1
if (counter === 0) {
console.log('All tests passed.')
setTimeout(function () {
process.exit();
}, 500)
}
}
// Test pipeing to a request object
s.once('/push', server.createPostValidator("mydata"));
var mydata = new stream.Stream();
mydata.readable = true
counter++
var r1 = request.put({url:'http://localhost:3453/push'}, function () {
check();
})
mydata.pipe(r1)
mydata.emit('data', 'mydata');
mydata.emit('end');
// Test pipeing from a request object.
s.once('/pull', server.createGetResponse("mypulldata"));
var mypulldata = new stream.Stream();
mypulldata.writable = true
counter++
request({url:'http://localhost:3453/pull'}).pipe(mypulldata)
var d = '';
mypulldata.write = function (chunk) {
d += chunk;
}
mypulldata.end = function () {
assert.equal(d, 'mypulldata');
check();
};
s.on('/cat', function (req, resp) {
if (req.method === "GET") {
resp.writeHead(200, {'content-type':'text/plain-test', 'content-length':4});
resp.end('asdf')
} else if (req.method === "PUT") {
assert.equal(req.headers['content-type'], 'text/plain-test');
assert.equal(req.headers['content-length'], 4)
var validate = '';
req.on('data', function (chunk) {validate += chunk})
req.on('end', function () {
resp.writeHead(201);
resp.end();
assert.equal(validate, 'asdf');
check();
})
}
})
s.on('/pushjs', function (req, resp) {
if (req.method === "PUT") {
assert.equal(req.headers['content-type'], 'text/javascript');
check();
}
})
s.on('/catresp', function (req, resp) {
request.get('http://localhost:3453/cat').pipe(resp)
})
s.on('/doodle', function (req, resp) {
if (req.headers['x-oneline-proxy']) {
resp.setHeader('x-oneline-proxy', 'yup')
}
resp.writeHead('200', {'content-type':'image/png'})
fs.createReadStream(path.join(__dirname, 'googledoodle.png')).pipe(resp)
})
s.on('/onelineproxy', function (req, resp) {
var x = request('http://localhost:3453/doodle')
req.pipe(x)
x.pipe(resp)
})
counter++
fs.createReadStream(__filename).pipe(request.put('http://localhost:3453/pushjs'))
counter++
request.get('http://localhost:3453/cat').pipe(request.put('http://localhost:3453/cat'))
counter++
request.get('http://localhost:3453/catresp', function (e, resp, body) {
assert.equal(resp.headers['content-type'], 'text/plain-test');
assert.equal(resp.headers['content-length'], 4)
check();
})
var doodleWrite = fs.createWriteStream(path.join(__dirname, 'test.png'))
counter++
request.get('http://localhost:3453/doodle').pipe(doodleWrite)
doodleWrite.on('close', function () {
assert.deepEqual(fs.readFileSync(path.join(__dirname, 'googledoodle.png')), fs.readFileSync(path.join(__dirname, 'test.png')))
check()
})
process.on('exit', function () {
fs.unlinkSync(path.join(__dirname, 'test.png'))
})
counter++
request.get({uri:'http://localhost:3453/onelineproxy', headers:{'x-oneline-proxy':'nope'}}, function (err, resp, body) {
assert.equal(resp.headers['x-oneline-proxy'], 'yup')
check()
})
s.on('/afterresponse', function (req, resp) {
resp.write('d')
resp.end()
})
counter++
var afterresp = request.post('http://localhost:3453/afterresponse').on('response', function () {
var v = new ValidationStream('d')
afterresp.pipe(v)
v.on('end', check)
})
s.on('/forward1', function (req, resp) {
resp.writeHead(302, {location:'/forward2'})
resp.end()
})
s.on('/forward2', function (req, resp) {
resp.writeHead('200', {'content-type':'image/png'})
resp.write('d')
resp.end()
})
counter++
var validateForward = new ValidationStream('d')
validateForward.on('end', check)
request.get('http://localhost:3453/forward1').pipe(validateForward)
// Test pipe options
s.once('/opts', server.createGetResponse('opts response'));
var optsStream = new stream.Stream();
optsStream.writable = true
var optsData = '';
optsStream.write = function (buf) {
optsData += buf;
if (optsData === 'opts response') {
setTimeout(check, 10);
}
}
optsStream.end = function () {
assert.fail('end called')
};
counter++
request({url:'http://localhost:3453/opts'}).pipe(optsStream, { end : false })
})

16
test/node_modules/request/tests/test-pool.js generated vendored Normal file
View File

@@ -0,0 +1,16 @@
var request = require('../main')
, http = require('http')
, assert = require('assert')
;
var s = http.createServer(function (req, resp) {
resp.statusCode = 200;
resp.end('asdf');
}).listen(8080, function () {
request({'url': 'http://localhost:8080', 'pool': false}, function (e, resp) {
var agent = resp.request.agent;
assert.strictEqual(typeof agent, 'boolean');
assert.strictEqual(agent, false);
s.close();
});
});

View File

@@ -0,0 +1,60 @@
var server = require('./server')
, assert = require('assert')
, request = require('../main.js')
var s = server.createServer()
var ss = server.createSSLServer()
var sUrl = 'http://localhost:' + s.port
var ssUrl = 'https://localhost:' + ss.port
s.listen(s.port, bouncy(s, ssUrl))
ss.listen(ss.port, bouncy(ss, sUrl))
var hits = {}
var expect = {}
var pending = 0
function bouncy (s, server) { return function () {
var redirs = { a: 'b'
, b: 'c'
, c: 'd'
, d: 'e'
, e: 'f'
, f: 'g'
, g: 'h'
, h: 'end' }
var perm = true
Object.keys(redirs).forEach(function (p) {
var t = redirs[p]
// switch type each time
var type = perm ? 301 : 302
perm = !perm
s.on('/' + p, function (req, res) {
res.writeHead(type, { location: server + '/' + t })
res.end()
})
})
s.on('/end', function (req, res) {
var h = req.headers['x-test-key']
hits[h] = true
pending --
if (pending === 0) done()
})
}}
for (var i = 0; i < 5; i ++) {
pending ++
var val = 'test_' + i
expect[val] = true
request({ url: (i % 2 ? sUrl : ssUrl) + '/a'
, headers: { 'x-test-key': val } })
}
function done () {
assert.deepEqual(hits, expect)
process.exit(0)
}

39
test/node_modules/request/tests/test-proxy.js generated vendored Normal file
View File

@@ -0,0 +1,39 @@
var server = require('./server')
, events = require('events')
, stream = require('stream')
, assert = require('assert')
, fs = require('fs')
, request = require('../main.js')
, path = require('path')
, util = require('util')
;
var port = 6768
, called = false
, proxiedHost = 'google.com'
;
var s = server.createServer(port)
s.listen(port, function () {
s.on('http://google.com/', function (req, res) {
called = true
assert.equal(req.headers.host, proxiedHost)
res.writeHeader(200)
res.end()
})
request ({
url: 'http://'+proxiedHost,
proxy: 'http://localhost:'+port
/*
//should behave as if these arguments where passed:
url: 'http://localhost:'+port,
headers: {host: proxiedHost}
//*/
}, function (err, res, body) {
s.close()
})
})
process.on('exit', function () {
assert.ok(called, 'the request must be made to the proxy server')
})

28
test/node_modules/request/tests/test-qs.js generated vendored Normal file
View File

@@ -0,0 +1,28 @@
var request = request = require('../main.js')
, assert = require('assert')
;
// Test adding a querystring
var req1 = request.get({ uri: 'http://www.google.com', qs: { q : 'search' }})
setTimeout(function() {
assert.equal('/?q=search', req1.path)
}, 1)
// Test replacing a querystring value
var req2 = request.get({ uri: 'http://www.google.com?q=abc', qs: { q : 'search' }})
setTimeout(function() {
assert.equal('/?q=search', req2.path)
}, 1)
// Test appending a querystring value to the ones present in the uri
var req3 = request.get({ uri: 'http://www.google.com?x=y', qs: { q : 'search' }})
setTimeout(function() {
assert.equal('/?x=y&q=search', req3.path)
}, 1)
// Test leaving a querystring alone
var req4 = request.get({ uri: 'http://www.google.com?x=y'})
setTimeout(function() {
assert.equal('/?x=y', req4.path)
}, 1)

154
test/node_modules/request/tests/test-redirect.js generated vendored Normal file
View File

@@ -0,0 +1,154 @@
var server = require('./server')
, assert = require('assert')
, request = require('../main.js')
, Cookie = require('../vendor/cookie')
, Jar = require('../vendor/cookie/jar')
var s = server.createServer()
s.listen(s.port, function () {
var server = 'http://localhost:' + s.port;
var hits = {}
var passed = 0;
bouncer(301, 'temp')
bouncer(302, 'perm')
bouncer(302, 'nope')
function bouncer(code, label) {
var landing = label+'_landing';
s.on('/'+label, function (req, res) {
hits[label] = true;
res.writeHead(code, {
'location':server + '/'+landing,
'set-cookie': 'ham=eggs'
})
res.end()
})
s.on('/'+landing, function (req, res) {
if (req.method !== 'GET') { // We should only accept GET redirects
console.error("Got a non-GET request to the redirect destination URL");
res.writeHead(400);
res.end();
return;
}
// Make sure the cookie doesn't get included twice, see #139:
// Make sure cookies are set properly after redirect
assert.equal(req.headers.cookie, 'foo=bar; quux=baz; ham=eggs');
hits[landing] = true;
res.writeHead(200)
res.end(landing)
})
}
// Permanent bounce
var jar = new Jar()
jar.add(new Cookie('quux=baz'))
request({uri: server+'/perm', jar: jar, headers: {cookie: 'foo=bar'}}, function (er, res, body) {
if (er) throw er
if (res.statusCode !== 200) throw new Error('Status is not 200: '+res.statusCode)
assert.ok(hits.perm, 'Original request is to /perm')
assert.ok(hits.perm_landing, 'Forward to permanent landing URL')
assert.equal(body, 'perm_landing', 'Got permanent landing content')
passed += 1
done()
})
// Temporary bounce
request({uri: server+'/temp', jar: jar, headers: {cookie: 'foo=bar'}}, function (er, res, body) {
if (er) throw er
if (res.statusCode !== 200) throw new Error('Status is not 200: '+res.statusCode)
assert.ok(hits.temp, 'Original request is to /temp')
assert.ok(hits.temp_landing, 'Forward to temporary landing URL')
assert.equal(body, 'temp_landing', 'Got temporary landing content')
passed += 1
done()
})
// Prevent bouncing.
request({uri:server+'/nope', jar: jar, headers: {cookie: 'foo=bar'}, followRedirect:false}, function (er, res, body) {
if (er) throw er
if (res.statusCode !== 302) throw new Error('Status is not 302: '+res.statusCode)
assert.ok(hits.nope, 'Original request to /nope')
assert.ok(!hits.nope_landing, 'No chasing the redirect')
assert.equal(res.statusCode, 302, 'Response is the bounce itself')
passed += 1
done()
})
// Should not follow post redirects by default
request.post(server+'/temp', { jar: jar, headers: {cookie: 'foo=bar'}}, function (er, res, body) {
if (er) throw er
if (res.statusCode !== 301) throw new Error('Status is not 301: '+res.statusCode)
assert.ok(hits.temp, 'Original request is to /temp')
assert.ok(!hits.temp_landing, 'No chasing the redirect when post')
assert.equal(res.statusCode, 301, 'Response is the bounce itself')
passed += 1
done()
})
// Should follow post redirects when followAllRedirects true
request.post({uri:server+'/temp', followAllRedirects:true, jar: jar, headers: {cookie: 'foo=bar'}}, function (er, res, body) {
if (er) throw er
if (res.statusCode !== 200) throw new Error('Status is not 200: '+res.statusCode)
assert.ok(hits.temp, 'Original request is to /temp')
assert.ok(hits.temp_landing, 'Forward to temporary landing URL')
assert.equal(body, 'temp_landing', 'Got temporary landing content')
passed += 1
done()
})
request.post({uri:server+'/temp', followAllRedirects:false, jar: jar, headers: {cookie: 'foo=bar'}}, function (er, res, body) {
if (er) throw er
if (res.statusCode !== 301) throw new Error('Status is not 301: '+res.statusCode)
assert.ok(hits.temp, 'Original request is to /temp')
assert.ok(!hits.temp_landing, 'No chasing the redirect')
assert.equal(res.statusCode, 301, 'Response is the bounce itself')
passed += 1
done()
})
// Should not follow delete redirects by default
request.del(server+'/temp', { jar: jar, headers: {cookie: 'foo=bar'}}, function (er, res, body) {
if (er) throw er
if (res.statusCode < 301) throw new Error('Status is not a redirect.')
assert.ok(hits.temp, 'Original request is to /temp')
assert.ok(!hits.temp_landing, 'No chasing the redirect when delete')
assert.equal(res.statusCode, 301, 'Response is the bounce itself')
passed += 1
done()
})
// Should not follow delete redirects even if followRedirect is set to true
request.del(server+'/temp', { followRedirect: true, jar: jar, headers: {cookie: 'foo=bar'}}, function (er, res, body) {
if (er) throw er
if (res.statusCode !== 301) throw new Error('Status is not 301: '+res.statusCode)
assert.ok(hits.temp, 'Original request is to /temp')
assert.ok(!hits.temp_landing, 'No chasing the redirect when delete')
assert.equal(res.statusCode, 301, 'Response is the bounce itself')
passed += 1
done()
})
// Should follow delete redirects when followAllRedirects true
request.del(server+'/temp', {followAllRedirects:true, jar: jar, headers: {cookie: 'foo=bar'}}, function (er, res, body) {
if (er) throw er
if (res.statusCode !== 200) throw new Error('Status is not 200: '+res.statusCode)
assert.ok(hits.temp, 'Original request is to /temp')
assert.ok(hits.temp_landing, 'Forward to temporary landing URL')
assert.equal(body, 'temp_landing', 'Got temporary landing content')
passed += 1
done()
})
var reqs_done = 0;
function done() {
reqs_done += 1;
if(reqs_done == 9) {
console.log(passed + ' tests passed.')
s.close()
}
}
})

13
test/node_modules/request/tests/test-s3.js generated vendored Normal file
View File

@@ -0,0 +1,13 @@
var request = require('../main')
var r = request.get('https://log.curlybracecast.com.s3.amazonaws.com/',
{ aws:
{ key: 'AKIAI6KIQRRVMGK3WK5Q'
, secret: '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'
, bucket: 'log.curlybracecast.com'
}
}, function (e, resp, body) {
console.log(r.headers)
console.log(body)
}
)

87
test/node_modules/request/tests/test-timeout.js generated vendored Normal file
View File

@@ -0,0 +1,87 @@
var server = require('./server')
, events = require('events')
, stream = require('stream')
, assert = require('assert')
, request = require('../main.js')
;
var s = server.createServer();
var expectedBody = "waited";
var remainingTests = 5;
s.listen(s.port, function () {
// Request that waits for 200ms
s.on('/timeout', function (req, resp) {
setTimeout(function(){
resp.writeHead(200, {'content-type':'text/plain'})
resp.write(expectedBody)
resp.end()
}, 200);
});
// Scenario that should timeout
var shouldTimeout = {
url: s.url + "/timeout",
timeout:100
}
request(shouldTimeout, function (err, resp, body) {
assert.equal(err.code, "ETIMEDOUT");
checkDone();
})
// Scenario that shouldn't timeout
var shouldntTimeout = {
url: s.url + "/timeout",
timeout:300
}
request(shouldntTimeout, function (err, resp, body) {
assert.equal(err, null);
assert.equal(expectedBody, body)
checkDone();
})
// Scenario with no timeout set, so shouldn't timeout
var noTimeout = {
url: s.url + "/timeout"
}
request(noTimeout, function (err, resp, body) {
assert.equal(err);
assert.equal(expectedBody, body)
checkDone();
})
// Scenario with a negative timeout value, should be treated a zero or the minimum delay
var negativeTimeout = {
url: s.url + "/timeout",
timeout:-1000
}
request(negativeTimeout, function (err, resp, body) {
assert.equal(err.code, "ETIMEDOUT");
checkDone();
})
// Scenario with a float timeout value, should be rounded by setTimeout anyway
var floatTimeout = {
url: s.url + "/timeout",
timeout: 100.76
}
request(floatTimeout, function (err, resp, body) {
assert.equal(err.code, "ETIMEDOUT");
checkDone();
})
function checkDone() {
if(--remainingTests == 0) {
s.close();
console.log("All tests passed.");
}
}
})

14
test/node_modules/request/tests/test-toJSON.js generated vendored Normal file
View File

@@ -0,0 +1,14 @@
var request = require('../main')
, http = require('http')
, assert = require('assert')
;
var s = http.createServer(function (req, resp) {
resp.statusCode = 200
resp.end('asdf')
}).listen(8080, function () {
var r = request('http://localhost:8080', function (e, resp) {
assert.equal(JSON.parse(JSON.stringify(r)).response.statusCode, 200)
s.close()
})
})

62
test/node_modules/request/tests/test-tunnel.js generated vendored Normal file
View File

@@ -0,0 +1,62 @@
// test that we can tunnel a https request over an http proxy
// keeping all the CA and whatnot intact.
//
// Note: this requires that squid is installed.
// If the proxy fails to start, we'll just log a warning and assume success.
var server = require('./server')
, assert = require('assert')
, request = require('../main.js')
, fs = require('fs')
, path = require('path')
, caFile = path.resolve(__dirname, 'ssl/npm-ca.crt')
, ca = fs.readFileSync(caFile)
, child_process = require('child_process')
, sqConf = path.resolve(__dirname, 'squid.conf')
, sqArgs = ['-f', sqConf, '-N', '-d', '5']
, proxy = 'http://localhost:3128'
, hadError = null
var squid = child_process.spawn('squid', sqArgs);
var ready = false
squid.stderr.on('data', function (c) {
console.error('SQUIDERR ' + c.toString().trim().split('\n')
.join('\nSQUIDERR '))
ready = c.toString().match(/ready to serve requests/i)
})
squid.stdout.on('data', function (c) {
console.error('SQUIDOUT ' + c.toString().trim().split('\n')
.join('\nSQUIDOUT '))
})
squid.on('exit', function (c) {
console.error('squid: exit '+c)
if (c && !ready) {
console.error('squid must be installed to run this test.')
console.error('skipping this test. please install squid and run again if you need to test tunneling.')
c = null
hadError = null
process.exit(0)
return
}
if (c) {
hadError = hadError || new Error('Squid exited with '+c)
}
if (hadError) throw hadError
})
setTimeout(function F () {
if (!ready) return setTimeout(F, 100)
request({ uri: 'https://registry.npmjs.org/request/'
, proxy: 'http://localhost:3128'
, ca: ca
, json: true }, function (er, body) {
hadError = er
console.log(er || typeof body)
if (!er) console.log("ok")
squid.kill('SIGKILL')
})
}, 100)

229
test/node_modules/request/tunnel.js generated vendored Normal file
View File

@@ -0,0 +1,229 @@
'use strict';
var net = require('net');
var tls = require('tls');
var http = require('http');
var https = require('https');
var events = require('events');
var assert = require('assert');
var util = require('util');
exports.httpOverHttp = httpOverHttp;
exports.httpsOverHttp = httpsOverHttp;
exports.httpOverHttps = httpOverHttps;
exports.httpsOverHttps = httpsOverHttps;
function httpOverHttp(options) {
var agent = new TunnelingAgent(options);
agent.request = http.request;
return agent;
}
function httpsOverHttp(options) {
var agent = new TunnelingAgent(options);
agent.request = http.request;
agent.createSocket = createSecureSocket;
return agent;
}
function httpOverHttps(options) {
var agent = new TunnelingAgent(options);
agent.request = https.request;
return agent;
}
function httpsOverHttps(options) {
var agent = new TunnelingAgent(options);
agent.request = https.request;
agent.createSocket = createSecureSocket;
return agent;
}
function TunnelingAgent(options) {
var self = this;
self.options = options || {};
self.proxyOptions = self.options.proxy || {};
self.maxSockets = self.options.maxSockets || http.Agent.defaultMaxSockets;
self.requests = [];
self.sockets = [];
self.on('free', function onFree(socket, host, port) {
for (var i = 0, len = self.requests.length; i < len; ++i) {
var pending = self.requests[i];
if (pending.host === host && pending.port === port) {
// Detect the request to connect same origin server,
// reuse the connection.
self.requests.splice(i, 1);
pending.request.onSocket(socket);
return;
}
}
socket.destroy();
self.removeSocket(socket);
});
}
util.inherits(TunnelingAgent, events.EventEmitter);
TunnelingAgent.prototype.addRequest = function addRequest(req, host, port) {
var self = this;
if (self.sockets.length >= this.maxSockets) {
// We are over limit so we'll add it to the queue.
self.requests.push({host: host, port: port, request: req});
return;
}
// If we are under maxSockets create a new one.
self.createSocket({host: host, port: port, request: req}, function(socket) {
socket.on('free', onFree);
socket.on('close', onCloseOrRemove);
socket.on('agentRemove', onCloseOrRemove);
req.onSocket(socket);
function onFree() {
self.emit('free', socket, host, port);
}
function onCloseOrRemove(err) {
self.removeSocket();
socket.removeListener('free', onFree);
socket.removeListener('close', onCloseOrRemove);
socket.removeListener('agentRemove', onCloseOrRemove);
}
});
};
TunnelingAgent.prototype.createSocket = function createSocket(options, cb) {
var self = this;
var placeholder = {};
self.sockets.push(placeholder);
var connectOptions = mergeOptions({}, self.proxyOptions, {
method: 'CONNECT',
path: options.host + ':' + options.port,
agent: false
});
if (connectOptions.proxyAuth) {
connectOptions.headers = connectOptions.headers || {};
connectOptions.headers['Proxy-Authorization'] = 'Basic ' +
new Buffer(connectOptions.proxyAuth).toString('base64');
}
debug('making CONNECT request');
var connectReq = self.request(connectOptions);
connectReq.useChunkedEncodingByDefault = false; // for v0.6
connectReq.once('response', onResponse); // for v0.6
connectReq.once('upgrade', onUpgrade); // for v0.6
connectReq.once('connect', onConnect); // for v0.7 or later
connectReq.once('error', onError);
connectReq.end();
function onResponse(res) {
// Very hacky. This is necessary to avoid http-parser leaks.
res.upgrade = true;
}
function onUpgrade(res, socket, head) {
// Hacky.
process.nextTick(function() {
onConnect(res, socket, head);
});
}
function onConnect(res, socket, head) {
connectReq.removeAllListeners();
socket.removeAllListeners();
if (res.statusCode === 200) {
assert.equal(head.length, 0);
debug('tunneling connection has established');
self.sockets[self.sockets.indexOf(placeholder)] = socket;
cb(socket);
} else {
debug('tunneling socket could not be established, statusCode=%d',
res.statusCode);
var error = new Error('tunneling socket could not be established, ' +
'sutatusCode=' + res.statusCode);
error.code = 'ECONNRESET';
options.request.emit('error', error);
self.removeSocket(placeholder);
}
}
function onError(cause) {
connectReq.removeAllListeners();
debug('tunneling socket could not be established, cause=%s\n',
cause.message, cause.stack);
var error = new Error('tunneling socket could not be established, ' +
'cause=' + cause.message);
error.code = 'ECONNRESET';
options.request.emit('error', error);
self.removeSocket(placeholder);
}
};
TunnelingAgent.prototype.removeSocket = function removeSocket(socket) {
var pos = this.sockets.indexOf(socket)
if (pos === -1) {
return;
}
this.sockets.splice(pos, 1);
var pending = this.requests.shift();
if (pending) {
// If we have pending requests and a socket gets closed a new one
// needs to be created to take over in the pool for the one that closed.
this.createSocket(pending, function(socket) {
pending.request.onSocket(socket);
});
}
};
function createSecureSocket(options, cb) {
var self = this;
TunnelingAgent.prototype.createSocket.call(self, options, function(socket) {
// 0 is dummy port for v0.6
var secureSocket = tls.connect(0, mergeOptions({}, self.options, {
socket: socket
}));
cb(secureSocket);
});
}
function mergeOptions(target) {
for (var i = 1, len = arguments.length; i < len; ++i) {
var overrides = arguments[i];
if (typeof overrides === 'object') {
var keys = Object.keys(overrides);
for (var j = 0, keyLen = keys.length; j < keyLen; ++j) {
var k = keys[j];
if (overrides[k] !== undefined) {
target[k] = overrides[k];
}
}
}
}
return target;
}
var debug;
if (process.env.NODE_DEBUG && /\btunnel\b/.test(process.env.NODE_DEBUG)) {
debug = function() {
var args = Array.prototype.slice.call(arguments);
if (typeof args[0] === 'string') {
args[0] = 'TUNNEL: ' + args[0];
} else {
args.unshift('TUNNEL:');
}
console.error.apply(console, args);
}
} else {
debug = function() {};
}
exports.debug = debug; // for test

19
test/node_modules/request/uuid.js generated vendored Normal file
View File

@@ -0,0 +1,19 @@
module.exports = function () {
var s = [], itoh = '0123456789ABCDEF';
// Make array of random hex digits. The UUID only has 32 digits in it, but we
// allocate an extra items to make room for the '-'s we'll be inserting.
for (var i = 0; i <36; i++) s[i] = Math.floor(Math.random()*0x10);
// Conform to RFC-4122, section 4.4
s[14] = 4; // Set 4 high bits of time_high field to version
s[19] = (s[19] & 0x3) | 0x8; // Specify 2 high bits of clock sequence
// Convert to hex chars
for (var i = 0; i <36; i++) s[i] = itoh[s[i]];
// Insert '-'s
s[8] = s[13] = s[18] = s[23] = '-';
return s.join('');
}

65
test/node_modules/request/vendor/cookie/index.js generated vendored Normal file
View File

@@ -0,0 +1,65 @@
/*!
* Tobi - Cookie
* Copyright(c) 2010 LearnBoost <dev@learnboost.com>
* MIT Licensed
*/
/**
* Module dependencies.
*/
var url = require('url');
/**
* Initialize a new `Cookie` with the given cookie `str` and `req`.
*
* @param {String} str
* @param {IncomingRequest} req
* @api private
*/
var Cookie = exports = module.exports = function Cookie(str, req) {
this.str = str;
// Map the key/val pairs
str.split(/ *; */).reduce(function(obj, pair){
var p = pair.indexOf('=');
var key = p > 0 ? pair.substring(0, p).trim() : pair.trim();
var lowerCasedKey = key.toLowerCase();
var value = p > 0 ? pair.substring(p + 1).trim() : true;
if (!obj.name) {
// First key is the name
obj.name = key;
obj.value = value;
}
else if (lowerCasedKey === 'httponly') {
obj.httpOnly = value;
}
else {
obj[lowerCasedKey] = value;
}
return obj;
}, this);
// Expires
this.expires = this.expires
? new Date(this.expires)
: Infinity;
// Default or trim path
this.path = this.path
? this.path.trim(): req
? url.parse(req.url).pathname: '/';
};
/**
* Return the original cookie string.
*
* @return {String}
* @api public
*/
Cookie.prototype.toString = function(){
return this.str;
};

72
test/node_modules/request/vendor/cookie/jar.js generated vendored Normal file
View File

@@ -0,0 +1,72 @@
/*!
* Tobi - CookieJar
* Copyright(c) 2010 LearnBoost <dev@learnboost.com>
* MIT Licensed
*/
/**
* Module dependencies.
*/
var url = require('url');
/**
* Initialize a new `CookieJar`.
*
* @api private
*/
var CookieJar = exports = module.exports = function CookieJar() {
this.cookies = [];
};
/**
* Add the given `cookie` to the jar.
*
* @param {Cookie} cookie
* @api private
*/
CookieJar.prototype.add = function(cookie){
this.cookies = this.cookies.filter(function(c){
// Avoid duplication (same path, same name)
return !(c.name == cookie.name && c.path == cookie.path);
});
this.cookies.push(cookie);
};
/**
* Get cookies for the given `req`.
*
* @param {IncomingRequest} req
* @return {Array}
* @api private
*/
CookieJar.prototype.get = function(req){
var path = url.parse(req.url).pathname
, now = new Date
, specificity = {};
return this.cookies.filter(function(cookie){
if (0 == path.indexOf(cookie.path) && now < cookie.expires
&& cookie.path.length > (specificity[cookie.name] || 0))
return specificity[cookie.name] = cookie.path.length;
});
};
/**
* Return Cookie string for the given `req`.
*
* @param {IncomingRequest} req
* @return {String}
* @api private
*/
CookieJar.prototype.cookieString = function(req){
var cookies = this.get(req);
if (cookies.length) {
return cookies.map(function(cookie){
return cookie.name + '=' + cookie.value;
}).join('; ');
}
};