Skip to content

Commit 642fbe4

Browse files
JPrevostdarrenjennings
authored andcommitted
require openssl if url is https (Kong#123)
Prior to this change, the generated code would throw `uninitialized constant OpenSSL NameError` Fixes Kong#97
1 parent 1ec847c commit 642fbe4

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/targets/ruby/native.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ module.exports = function (source, options) {
77

88
code.push('require \'uri\'')
99
.push('require \'net/http\'')
10-
.blank()
10+
11+
if (source.uriObj.protocol === 'https:') {
12+
code.push('require \'openssl\'')
13+
}
14+
15+
code.blank()
1116

1217
// To support custom methods we check for the supported methods
1318
// and if doesn't exist then we build a custom class for it

test/fixtures/output/ruby/native/https.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
require 'uri'
22
require 'net/http'
3+
require 'openssl'
34

45
url = URI("https://mockbin.com/har")
56

0 commit comments

Comments
 (0)