Skip to content

Commit 602af56

Browse files
committed
full functional PHP implementation
1 parent 1b6def9 commit 602af56

1 file changed

Lines changed: 17 additions & 3 deletions

File tree

‎src/targets/php.js‎

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ module.exports = function (options) {
66
var opts = util._extend({
77
indent: ' ',
88
noTags: false,
9+
maxRedirects: 10,
10+
timeout: 30,
911
closingTag: false
1012
}, options);
1113

@@ -21,16 +23,28 @@ module.exports = function (options) {
2123

2224
var curlOptions = [{
2325
escape: true,
24-
name: 'CURLOPT_port',
26+
name: 'CURLOPT_PORT',
2527
value: this.source.uriObj.port
2628
}, {
2729
escape: true,
2830
name: 'CURLOPT_URL',
29-
value: this.source.url
31+
value: this.source.fullUrl
3032
}, {
3133
escape: false,
3234
name: 'CURLOPT_RETURNTRANSFER',
3335
value: 'true'
36+
}, {
37+
escape: true,
38+
name: 'CURLOPT_ENCODING',
39+
value: ''
40+
}, {
41+
escape: false,
42+
name: 'CURLOPT_MAXREDIRS',
43+
value: opts.maxRedirects
44+
}, {
45+
escape: false,
46+
name: 'CURLOPT_TIMEOUT',
47+
value: opts.timeout
3448
}, {
3549
escape: false,
3650
name: 'CURLOPT_HTTP_VERSION',
@@ -50,7 +64,7 @@ module.exports = function (options) {
5064
var curlopts = [];
5165

5266
curlOptions.map(function (option) {
53-
if (option.value) {
67+
if (!~[null, undefined].indexOf(option.value)) {
5468
curlopts.push(util.format('%s => %s,', option.name, option.escape ? JSON.stringify(option.value) : option.value));
5569
}
5670
});

0 commit comments

Comments
 (0)