Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,18 @@ In the future the server certificate will be extracted from the BinarySecurityTo
### SSL
Just specify an http**s** address in any of the previous samples.

### HTTP Request options [Optional]

Add any of the available http request options like timeout, proxy etc. while sending a ws request.
List of all available options: [Request Options Callback](https://github.com/request/request#requestoptions-callback)
Pass on the options as a JSON Object to constructor argument of Http handler as shown below:

`````javascript

var handlers = [ new Addr("http://schemas.xmlsoap.org/ws/2004/08/addressing")
, new Http({timeout: 3000})
]
`````
### All together now
`````javascript
var ws = require('ws.js')
Expand Down Expand Up @@ -340,4 +352,3 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI


[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/yaronn/ws.js/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

39 changes: 28 additions & 11 deletions lib/handlers/client/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,36 @@ var utils = require('../../utils')

exports.HttpClientHandler = HttpClientHandler

function HttpClientHandler() {}
function HttpClientHandler() {
if(arguments.length == 1) {
this._options = arguments[0];
}
}

function jsonConcat(o1, o2) {
for (var key in o2) {
o1[key] = o2[key];
}
return o1;
}

HttpClientHandler.prototype.send = function(ctx, callback) {
request.post({ url: ctx.url
, body: ctx.request
, headers: { "SOAPAction": ctx.action
, "Content-Type": ctx.contentType
, "MIME-Version": "1.0"
}
, encoding: null
, rejectUnauthorized: false
, agentOptions: ctx.agentOptions
},
var options = { url: ctx.url,
body: ctx.request,
headers: { "SOAPAction": ctx.action,
"Content-Type": ctx.contentType,
"MIME-Version": "1.0"
},
encoding: null,
rejectUnauthorized: false,
agentOptions: ctx.agentOptions,
};

if(this._options !== 'undefined') {
options = jsonConcat(options, this._options);
}

request.post(options,
function (error, response, body) {
ctx.response = body
if (response) {
Expand Down