Skip to content

Commit

Permalink
Fixed several bugs, added tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Golo Roden committed May 26, 2015
1 parent 0ec89ea commit 60ac47e
Show file tree
Hide file tree
Showing 7 changed files with 304 additions and 70 deletions.
20 changes: 20 additions & 0 deletions .zuul.yml
@@ -0,0 +1,20 @@
ui: mocha-tdd

browsers:
- name: chrome
version: latest
- name: firefox
version: latest
- name: safari
version: latest
- name: ie
version: 10..latest

- name: iphone
version: latest
- name: ipad
version: latest
- name: android
version: latest

server: ./test/server/app.js
3 changes: 2 additions & 1 deletion Gruntfile.js
Expand Up @@ -15,6 +15,7 @@ module.exports = tourism({
server: [ 'test/**/*.js' ]
},
shell: {
'test-browser': 'zuul --ui mocha-tdd --local 8080 --open -- test/requestTests.js'
'test-browser': 'zuul --ui mocha-tdd --local 8080 --tunnel --open -- test/requestTests.js',
'test-browsers': 'zuul -- test/requestTests.js'
}
});
4 changes: 3 additions & 1 deletion README.md
Expand Up @@ -19,7 +19,7 @@ First you need to register http-browserify-2 as a replacement to the `http` and
}
```

Then you may use it in the same way as the aforementioned modules. Currently, the only function supported is `request`.
Then you may use it in the same way as the aforementioned modules. Currently, the functions [`request`](https://nodejs.org/api/http.html#http_http_request_options_callback) and [`get`](https://nodejs.org/api/http.html#http_http_get_options_callback) are implemented.

```javascript
var req = http.request({
Expand All @@ -34,6 +34,8 @@ var req = http.request({
req.end();
```

For further details on how to use these functions see their documentation.

## Running the build

This module can be built using [Grunt](http://gruntjs.com/). Besides running the tests, this also analyses the code. To run Grunt, go to the folder where you have installed http-browserify-2 and run `grunt`. You need to have [grunt-cli](https://github.com/gruntjs/grunt-cli) installed.
Expand Down
10 changes: 9 additions & 1 deletion lib/request.js
Expand Up @@ -16,6 +16,14 @@ var xhrStatus = {
var setupRequest = function (protocol) {
var http = {};

http.get = function (options, callback) {
if (typeof options === 'object') {
options.method = 'GET';
}

http.request(options, callback).end();
};

http.request = function (options, callback) {
var header,
req,
Expand All @@ -34,7 +42,7 @@ var setupRequest = function (protocol) {

options.protocol = protocol;
options.hostname = options.hostname || 'localhost';
options.port = options.port || 80;
options.port = options.port || (protocol === 'http' ? 80 : 443);
options.pathname = options.path.split('?')[0];
options.search = options.path.split('?')[1] || '';

Expand Down
4 changes: 4 additions & 0 deletions package.json
Expand Up @@ -16,7 +16,11 @@
"dependencies": {},
"devDependencies": {
"assertthat": "0.6.0",
"body-parser": "1.12.4",
"express": "4.12.4",
"grunt": "0.4.5",
"json-lines": "0.3.0",
"processenv": "0.1.0",
"tourism": "0.19.0"
},
"repository": {
Expand Down

0 comments on commit 60ac47e

Please sign in to comment.