File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11language : node_js
22node_js :
3- - " 0.8"
43 - " 0.10"
54 - " 0.12"
5+ - " iojs"
Original file line number Diff line number Diff line change 22 "author" :
" Felix Geisendörfer <[email protected] > (http://debuggable.com/)" ,
33 "name" : " form-data" ,
44 "description" : " A module to create readable \" multipart/form-data\" streams. Can be used to submit forms and file uploads to other web applications." ,
5- "version" : " 0.2.0 " ,
5+ "version" : " 1.0.0-rc0 " ,
66 "repository" : {
77 "type" : " git" ,
88 "url" : " git://github.com/felixge/node-form-data.git"
1212 "test" : " node test/run.js"
1313 },
1414 "engines" : {
15- "node" : " >= 0.8 "
15+ "node" : " >= 0.10 "
1616 },
1717 "dependencies" : {
1818 "async" : " ~0.9.0" ,
Original file line number Diff line number Diff line change @@ -12,3 +12,5 @@ common.assert = require('assert');
1212common . fake = require ( 'fake' ) ;
1313
1414common . port = 8432 ;
15+
16+ common . staticPort = 9432 ;
Original file line number Diff line number Diff line change @@ -8,7 +8,8 @@ var fs = require('fs');
88var FormData = require ( common . dir . lib + '/form_data' ) ;
99var IncomingForm = require ( 'formidable' ) . IncomingForm ;
1010
11- var remoteFile = 'http://nodejs.org/images/logo.png' ;
11+ // static server prepared for all tests
12+ var remoteFile = 'http://localhost:' + common . staticPort + '/unicycle.jpg' ;
1213
1314var FIELDS ;
1415var server ;
@@ -22,6 +23,7 @@ var parsedUrl = parseUrl(remoteFile)
2223 }
2324 ;
2425
26+ // request static file
2527http . request ( options , function ( res ) {
2628
2729 FIELDS = [
@@ -55,6 +57,7 @@ http.request(options, function(res) {
5557
5658} ) . end ( ) ;
5759
60+ // prepare form-receiving http server
5861server = http . createServer ( function ( req , res ) {
5962
6063 var form = new IncomingForm ( { uploadDir : common . dir . tmp } ) ;
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ var fs = require('fs');
88var FormData = require ( common . dir . lib + '/form_data' ) ;
99var IncomingForm = require ( 'formidable' ) . IncomingForm ;
1010
11- var remoteFile = 'http://nodejs.org/images/logo.png ' ;
11+ var remoteFile = 'http://localhost:' + common . staticPort + '/unicycle.jpg ';
1212
1313// wrap non simple values into function
1414// just to deal with ReadStream "autostart"
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ var fs = require('fs');
88var FormData = require ( common . dir . lib + '/form_data' ) ;
99var IncomingForm = require ( 'formidable' ) . IncomingForm ;
1010
11- var remoteFile = 'http://nodejs.org/images/logo.png ' ;
11+ var remoteFile = 'http://localhost:' + common . staticPort + '/unicycle.jpg ';
1212
1313// wrap non simple values into function
1414// just to deal with ReadStream "autostart"
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ var fs = require('fs');
88var FormData = require ( common . dir . lib + '/form_data' ) ;
99var IncomingForm = require ( 'formidable' ) . IncomingForm ;
1010
11- var remoteFile = 'http://nodejs.org/images/logo.png ' ;
11+ var remoteFile = 'http://localhost:' + common . staticPort + '/unicycle.jpg ';
1212
1313// wrap non simple values into function
1414// just to deal with ReadStream "autostart"
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ var fs = require('fs');
88var FormData = require ( common . dir . lib + '/form_data' ) ;
99var IncomingForm = require ( 'formidable' ) . IncomingForm ;
1010
11- var remoteFile = 'http://nodejs.org/images/logo.png ' ;
11+ var remoteFile = 'http://localhost:' + common . staticPort + '/unicycle.jpg ';
1212
1313// wrap non simple values into function
1414// just to deal with ReadStream "autostart"
Original file line number Diff line number Diff line change 11#!/usr/bin/env node
2+ var static = require ( './static' ) ;
23var far = require ( 'far' ) . create ( ) ;
34
45if ( process . env . verbose )
@@ -9,4 +10,8 @@ if (process.env.verbose)
910far . add ( __dirname ) ;
1011far . include ( / t e s t - .* \. j s $ / ) ;
1112
12- far . execute ( ) ;
13+ // start static server for all tests
14+ static ( function ( staticServer )
15+ {
16+ far . execute ( ) ;
17+ } ) ;
Original file line number Diff line number Diff line change 1+ // serves static files
2+ var http = require ( 'http' ) ;
3+ var fs = require ( 'fs' ) ;
4+ var path = require ( 'path' ) ;
5+ var mime = require ( 'mime-types' ) ;
6+ var common = require ( './common' ) ;
7+
8+ module . exports = function ( callback ) {
9+ var server = http . createServer ( function ( req , res ) {
10+
11+ var target = path . join ( common . dir . fixture , req . url ) ;
12+ var stat = fs . statSync ( target ) ;
13+
14+ res . writeHead ( 200 , {
15+ 'Content-Type' : mime . lookup ( target ) ,
16+ 'Content-Length' : stat . size
17+ } ) ;
18+
19+ fs . createReadStream ( target ) . pipe ( res ) ;
20+ } ) ;
21+ server . listen ( common . staticPort , callback . bind ( undefined , server ) ) ;
22+ } ;
You can’t perform that action at this time.
0 commit comments