mirror of
				https://github.com/therootcompany/request.js
				synced 2025-10-31 12:32:47 +00:00 
			
		
		
		
	allow pipe-able inputs
This commit is contained in:
		
							parent
							
								
									4f3fe38ee4
								
							
						
					
					
						commit
						5b5cd36aa5
					
				
							
								
								
									
										10
									
								
								index.js
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								index.js
									
									
									
									
									
								
							| @ -240,9 +240,14 @@ function setDefaults(defs) { | |||||||
|         if (_body) { |         if (_body) { | ||||||
|             // Most APIs expect (or require) Content-Length except in the case of multipart uploads
 |             // Most APIs expect (or require) Content-Length except in the case of multipart uploads
 | ||||||
|             // Transfer-Encoding: Chunked (the default) is generally only well-supported downstream
 |             // Transfer-Encoding: Chunked (the default) is generally only well-supported downstream
 | ||||||
|  |             if ( | ||||||
|  |                 'undefined' !== typeof _body.byteLength || | ||||||
|  |                 'undefined' !== typeof _body.length | ||||||
|  |             ) { | ||||||
|                 finalOpts.headers['Content-Length'] = |                 finalOpts.headers['Content-Length'] = | ||||||
|                     _body.byteLength || _body.length; |                     _body.byteLength || _body.length; | ||||||
|             } |             } | ||||||
|  |         } | ||||||
|         if (opts.auth) { |         if (opts.auth) { | ||||||
|             // if opts.uri specifies auth it will be parsed by url.parse and passed directly to the http module
 |             // if opts.uri specifies auth it will be parsed by url.parse and passed directly to the http module
 | ||||||
|             if ('string' !== typeof opts.auth) { |             if ('string' !== typeof opts.auth) { | ||||||
| @ -359,10 +364,13 @@ function setDefaults(defs) { | |||||||
|         if (_body) { |         if (_body) { | ||||||
|             debug("\n[urequest] '" + finalOpts.method + "' (request) body"); |             debug("\n[urequest] '" + finalOpts.method + "' (request) body"); | ||||||
|             debug(_body); |             debug(_body); | ||||||
|  |             if ('function' === typeof _body.pipe) { | ||||||
|                 // used for chunked encoding
 |                 // used for chunked encoding
 | ||||||
|             //req.write(_body);
 |                 _body.pipe(req); | ||||||
|  |             } else { | ||||||
|                 // used for known content-length
 |                 // used for known content-length
 | ||||||
|                 req.end(_body); |                 req.end(_body); | ||||||
|  |             } | ||||||
|         } else { |         } else { | ||||||
|             req.end(); |             req.end(); | ||||||
|         } |         } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user