Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Querystring option #176

Merged
merged 8 commits into from
Feb 21, 2012
Merged

Querystring option #176

merged 8 commits into from
Feb 21, 2012

Conversation

csainty
Copy link
Contributor

@csainty csainty commented Feb 18, 2012

#172

Took a stab at adding support for passing in a querystring option parameter.
First contribution to the project and I am still pretty new to Node, so happy to talk over any problems in code.

It got a bit interesting with oAuth, the oAuth code supports pulling its parameters from the body or the querystring, with the querystring taking preference with a basic truthy test. This looked wrong to me, but the change I have made would cause a change in functionality in certain circumstances.

Also included is a js based test runner if you want to point the npm test script at it. Running windows here, so needed something platform agnostic.

Chris Sainty added 4 commits February 18, 2012 23:44
…g values that is merged (taking precedence over) with the querystring passed in the uri string.
Also fixed what appears to be a bug in oAuth where the querystring will trump the request body. If this is deliberate then perhaps check for entries in the querystring rather than just it's existence since it is always going to exist now.
@mikeal
Copy link
Member

mikeal commented Feb 19, 2012

the query option should be named qs to match the composable API.

also, it's unsafe to set properties on self.uri because the underlying url parsing library in core is subject to change. it would be better to simply re-compose the url string with the new querystring and reset self.uri to a new url.parse(newurl).

oAuth is dark voodoo that nobody really understands. it's unclear to me how signing should work if both the querystring and form body are present (which is a totally legal HTTP request). i would just leave oAuth alone and once someone is trying to use both querystring arguments and form bodies we can see how different servers react and tweak as necessary.

…red to be conflicts with the qs = require('querystring'). These are no longer present though and must have been unrelated.
@csainty
Copy link
Contributor Author

csainty commented Feb 19, 2012

I'll need to have a think about the self.uri side of things. I want to support appending qs {} values to an existing querystring that was part of the uri.
I'll take a look later tonight after I have a think on it. Spotted a bug as well that I will fix for the next update.

Chris Sainty added 2 commits February 19, 2012 20:17
…oauth tests. This also lets me revert some of the changes I had to make to the test server and proxy tests
…ing request uri, instead it recreates a new one. This allows me to revert all the other changes I had to make previously and gives a nice clean commit that is self contained.
@csainty
Copy link
Contributor Author

csainty commented Feb 19, 2012

Ok I went away and thought about it a bit. The change is now self contained and much cleaner while still passing all tests.
The only piece I am unhappy with is where it formats then parses the uri object. It feels like too much work for simply merging querystrings.
At this stage I do not see a good work around other than removing the dependency on self.uri as an actual uri object and instead making it our own structure that can be tweaked without the double processing.

@mikeal
Copy link
Member

mikeal commented Feb 20, 2012

the patch looks great now but i'm wondering what the run.js is?

we have a shell script that execs all the tests and can be executed using npm test.

@csainty
Copy link
Contributor Author

csainty commented Feb 20, 2012

The current script is a bash script. I'm on windows here and it doesn't run. I can drop it from the commit if you like, but thought it might be of interest.

@mikeal
Copy link
Member

mikeal commented Feb 20, 2012

good point.

i'll take it but please remove the bash script, change package.json to use this, and change it to running a static list of files because people tend to keep tests that aren't passing in that directory without checking them in.

… cross-platform.

Also now based off a static list of files so failing tests can be kept in the tests folder while being worked on.
@csainty
Copy link
Contributor Author

csainty commented Feb 20, 2012

Done.

Keep in mind this commit is now behind master a little and there are extra tests that will need to be added to static list in run.js.

Rebase etiquette is something I still am a little unsure of, I read conflicting things about whether I should rebase, merge or leave it to the project owner a this point.

@mikeal
Copy link
Member

mikeal commented Feb 21, 2012

if it merged cleanly i won't rebase, i'll just merge it now and then add the other tests in myself.

mikeal added a commit that referenced this pull request Feb 21, 2012
@mikeal mikeal merged commit 10a5e23 into request:master Feb 21, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants