Comments (6)
Haha, not overwhelmed in the least. Always happy to work with a motivated and talented coder.
Initially, needle didn't set the body as resp.body, so the only way to get the body was by using the third argument. Then I started storing the contents in resp.body an simply linking the third argument to that variable, and updated (some?) of the examples in the README to reflect this.
I'm not so sure, though, about the community "having settled" on the 2-argument callback, because of the uncountable and different scenarios for each and every app or library out there. I was actually thinking of having a way to retrieve the original, raw response besides the parsed/decoded one, although haven't really wrapped my mind around this.
Anyway, does it really hurt to have a third argument? Are there any libraries that complain about this? If so, sure, let's implement some kind of detection -- just remember to keep it lean! :)
from needle.
See my line comment in the pull request -- it illustrates the problem a bit.
As far as I'm aware, people call this
asyncFunction(function cb(err, obj) { ... });
Node.JS callback style. It's the style used in the core libraries and style generally approved of -- consider for example the visionmedia/node-thunkify library which converts "regular node functions into a function which returns a thunk", s "regular node function" being one which accepts a two-argument callback.
Having said that, I have to admit I'm really really new to Node.JS, so I could be mistaken. But generally this is an area where I know what I'm doing. :) The patch will be a few lines at most, but I feel pretty strongly about that a library such as this should behave in a standards-compliant way. Doing this correctly opens up the possibility to integrate with all kinds of libraries. I'm probably going to code a few more examples tomorrow that illustrate the flexibility this brings.
from needle.
Also, i will look into returning the raw streams. Now that we've refactored that part, all we need to do is come up with an elegant way to provide access to the 'pipeline' variable. I'll see if I can come up with something that doesn't introduce any dependencies -- but with an optional dependency, I think there are elegant ways to do this!
from needle.
Sure, go ahead. I guess something like resp.original_body or resp.raw_body would work (assuming callback mode).
I'll take a second look and merge your PR in a while.
from needle.
Nah I have something better in mind, giving access to all streams in the
pipeline without additional function calls (but staying compatible with the
current interface).
I'll come up with something tomorrow.
On Tuesday, March 25, 2014, TomΓ‘s Pollak [email protected] wrote:
Sure, go ahead. I guess something like resp.original_body or resp.raw_body
would work (assuming callback mode).I'll take a second look and merge your PR in a while.
β
Reply to this email directly or view it on GitHubhttps://github.com//issues/53#issuecomment-38627400
.
Sent from my iPhone
from needle.
By the way, with regards to the "original_body", it is going to look like this:
var rawStream = needle.get(...).raw ();
Notice the .raw() behind it -- elegant way to provide access. You can get access to the whole pipeline like this:
var pipeline = needle.get(...).pipeline()
But I'm not sure about that last one, might be a bit too much feature-creep.
from needle.
Related Issues (20)
- Test failures on node v14-v16 HOT 3
- Test failures on node v4-v12
- Incorrect parsing of complex JS nested objects in POST request HOT 5
- Mangled file content when multipart-POSTing a file with a "text/*" content type HOT 2
- Very infrequent TypeError: iconv.encodingExists is not a function
- Tunnelling doesn't work in v3.1.0 HOT 12
- Proposal: Supporting User-Defined "Follow If" Conditions
- Piping needle request to Express response won't set the correct headers
- Multiple Files Upload Renames Input Field
- Uncaught asynchronous error
- Remote end closed socket abruptly errors HOT 2
- a ':' in nonce breaks digest authentication HOT 1
- Digest MD5 not working with Geovision IP Camera
- Uncaught ECONNRESET exception
- needle.get cannot guaranty getting the http stream HOT 2
- FEATURE: Retry HOT 1
- follow_set_cookies -> not working!!!
- Bug in 3.3.0: accidental creation of `global.signal`, gets caught in strict UTs
- README recommends mikeal's request HOT 3
- Multipart uploads strips date values in the request body HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from needle.