@@ -180,15 +180,19 @@ class WebSocket extends EventEmitter {
180180 * @param {(net.Socket|tls.Socket) } socket The network socket between the
181181 * server and client
182182 * @param {Buffer } head The first packet of the upgraded stream
183- * @param {Number } [maxPayload=0] The maximum allowed message size
183+ * @param {Object } options Options object
184+ * @param {Number } [options.maxPayload=0] The maximum allowed message size
185+ * @param {Boolean } [options.skipUTF8Validation=false] Specifies whether or
186+ * not to skip UTF-8 validation for text and close messages
184187 * @private
185188 */
186- setSocket ( socket , head , maxPayload ) {
189+ setSocket ( socket , head , options ) {
187190 const receiver = new Receiver ( {
188191 binaryType : this . binaryType ,
189192 extensions : this . _extensions ,
190193 isServer : this . _isServer ,
191- maxPayload
194+ maxPayload : options . maxPayload ,
195+ skipUTF8Validation : options . skipUTF8Validation
192196 } ) ;
193197
194198 this . _sender = new Sender ( socket , this . _extensions ) ;
@@ -575,12 +579,15 @@ module.exports = WebSocket;
575579 * redirects
576580 * @param {Number } [options.maxRedirects=10] The maximum number of redirects
577581 * allowed
582+ * @param {Boolean } [options.skipUTF8Validation=false] Specifies whether or
583+ * not to skip UTF-8 validation for text and close messages
578584 * @private
579585 */
580586function initAsClient ( websocket , address , protocols , options ) {
581587 const opts = {
582588 protocolVersion : protocolVersions [ 1 ] ,
583589 maxPayload : 100 * 1024 * 1024 ,
590+ skipUTF8Validation : false ,
584591 perMessageDeflate : true ,
585592 followRedirects : false ,
586593 maxRedirects : 10 ,
@@ -832,7 +839,10 @@ function initAsClient(websocket, address, protocols, options) {
832839 perMessageDeflate ;
833840 }
834841
835- websocket . setSocket ( socket , head , opts . maxPayload ) ;
842+ websocket . setSocket ( socket , head , {
843+ maxPayload : opts . maxPayload ,
844+ skipUTF8Validation : opts . skipUTF8Validation
845+ } ) ;
836846 } ) ;
837847}
838848
0 commit comments