File tree Expand file tree Collapse file tree 3 files changed +6
-14
lines changed Expand file tree Collapse file tree 3 files changed +6
-14
lines changed Original file line number Diff line number Diff line change @@ -26,7 +26,6 @@ namespace node {
26
26
27
27
using v8::Array;
28
28
using v8::ArrayBuffer;
29
- using v8::ArrayBufferView;
30
29
using v8::BackingStore;
31
30
using v8::Context;
32
31
using v8::EscapableHandleScope;
@@ -87,20 +86,13 @@ void LogSecret(
87
86
keylog_cb (ssl.get (), line.c_str ());
88
87
}
89
88
90
- bool SetALPN (const SSLPointer& ssl, const std::string& alpn) {
89
+ bool SetALPN (const SSLPointer& ssl, std::string_view alpn) {
91
90
return SSL_set_alpn_protos (
92
91
ssl.get (),
93
- reinterpret_cast <const uint8_t *>(alpn.c_str ()),
92
+ reinterpret_cast <const uint8_t *>(alpn.data ()),
94
93
alpn.length ()) == 0 ;
95
94
}
96
95
97
- bool SetALPN (const SSLPointer& ssl, Local<Value> alpn) {
98
- if (!alpn->IsArrayBufferView ())
99
- return false ;
100
- ArrayBufferViewContents<unsigned char > protos (alpn.As <ArrayBufferView>());
101
- return SSL_set_alpn_protos (ssl.get (), protos.data (), protos.length ()) == 0 ;
102
- }
103
-
104
96
MaybeLocal<Value> GetSSLOCSPResponse (
105
97
Environment* env,
106
98
SSL* ssl,
Original file line number Diff line number Diff line change @@ -33,9 +33,8 @@ void LogSecret(
33
33
const unsigned char * secret,
34
34
size_t secretlen);
35
35
36
- bool SetALPN (const SSLPointer& ssl, const std::string& alpn);
37
-
38
- bool SetALPN (const SSLPointer& ssl, v8::Local<v8::Value> alpn);
36
+ // TODO(tniessen): use std::u8string_view when we switch to C++20.
37
+ bool SetALPN (const SSLPointer& ssl, std::string_view alpn);
39
38
40
39
v8::MaybeLocal<v8::Value> GetSSLOCSPResponse (
41
40
Environment* env,
Original file line number Diff line number Diff line change @@ -1530,7 +1530,8 @@ void TLSWrap::SetALPNProtocols(const FunctionCallbackInfo<Value>& args) {
1530
1530
return env->ThrowTypeError (" Must give a Buffer as first argument" );
1531
1531
1532
1532
if (w->is_client ()) {
1533
- CHECK (SetALPN (w->ssl_ , args[0 ]));
1533
+ ArrayBufferViewContents<char > protos (args[0 ].As <ArrayBufferView>());
1534
+ CHECK (SetALPN (w->ssl_ , { protos.data (), protos.length () }));
1534
1535
} else {
1535
1536
CHECK (
1536
1537
w->object ()->SetPrivate (
You can’t perform that action at this time.
0 commit comments