Object built-in object

Object HttpsServer

https server object

The https server object is SslServer with HttpHandler Combining encapsulated objects makes it convenient to quickly build a server, which is logically equivalent to:

1 2 3
var svr = new net.SslServer(crt, key, addr, port, new http.Handler(function(req) { ... }));

Creation method:

1 2 3 4
var http = require("http"); var svr = new http.HttpsServer(crt, key, 443, function(req) { ... });

Inheritance

#lineWidth: 1.5 #font: Helvetica,sans-Serif #fontSize: 10 #leading: 1.6 #.this: fill=lightgray #.class: fill=white [<class>object|toString();toJSON()] [<class>TcpServer|new TcpServer()|socket;handler|start();stop()] [<class>HttpServer|new HttpServer()|maxHeadersCount;maxBodySize;enableEncoding;serverName|enableCrossOrigin()] [<this>HttpsServer|new HttpsServer()|verification;ca] [object] <:- [TcpServer] [TcpServer] <:- [HttpServer] [HttpServer] <:- [HttpsServer] TcpServer new TcpServer() socket handler start() stop() HttpServer new HttpServer() maxHeadersCount maxBodySize enableEncoding serverName enableCrossOrigin() HttpsServer new HttpsServer() verification ca object toString() toJSON()

Constructor

HttpsServer

HttpsServer constructor, listening at all local addresses

1 2 3
new HttpsServer(Array certs, Integer port, Handler hdlr);

Call parameters:

  • certs: Array, server certificate list
  • port: Integer, specify http Server listening port
  • hdlr: Handler, http Built-in message processor, processing function, chain processing array, routing object, see details

The format of certs is:

1 2 3 4 5 6 7 8 9 10 11
[{ name: "fibjs.org", crt: [X509Cert object], key: [PKey object] }, { name: "*.fibjs.org", crt: [X509Cert object], key: [PKey object] } ]

HttpsServer constructor

1 2 3 4
new HttpsServer(Array certs, String addr, Integer port, Handler hdlr);

Call parameters:

  • certs: Array, server certificate list
  • addr: String, specify http Server listening address, "" means listening on all addresses of this machine
  • port: Integer, specify http Server listening port
  • hdlr: Handler, http Built-in message processor, processing function, chain processing array, routing object, see details

The format of certs is:

1 2 3 4 5 6 7 8 9 10 11
[{ name: "fibjs.org", crt: [X509Cert object], key: [PKey object] }, { name: "*.fibjs.org", crt: [X509Cert object], key: [PKey object] } ]

HttpsServer constructor, listening at all local addresses

1 2 3 4
new HttpsServer(X509Cert crt, PKey key, Integer port, Handler hdlr);

Call parameters:

  • crt: X509Cert, X509Cert Certificate for client authentication server
  • key: PKey, PKey Private key, used to talk to the client
  • port: Integer, specify http Server listening port
  • hdlr: Handler, http Built-in message processor, processing function, chain processing array, routing object, see details

HttpsServer constructor

1 2 3 4 5
new HttpsServer(X509Cert crt, PKey key, String addr, Integer port, Handler hdlr);

Call parameters:

  • crt: X509Cert, X509Cert Certificate for client authentication server
  • key: PKey, PKey Private key, used to talk to the client
  • addr: String, specify http Server listening address, "" means listening on all addresses of this machine
  • port: Integer, specify http Server listening port
  • hdlr: Handler, http Built-in message processor, processing function, chain processing array, routing object, see details

Member attributes

verification

Integer, set the certificate verification mode, the default is VERIFY_NONE

1
Integer HttpsServer.verification;

ca

X509Cert, Client certificate verification ca

1
readonly X509Cert HttpsServer.ca;

maxHeadersCount

Integer, query and set the maximum number of request headers, the default is 128

1
Integer HttpsServer.maxHeadersCount;

maxBodySize

Integer, query and set the maximum size of the body, in MB, the default is 64

1
Integer HttpsServer.maxBodySize;

enableEncoding

Boolean, automatic decompression function switch, closed by default

1
Boolean HttpsServer.enableEncoding;

serverName

String, query and set the server name, the default is: fibjs/0.x.0

1
String HttpsServer.serverName;

socket

Socket, The server is currently listening Socket Object

1
readonly Socket HttpsServer.socket;

handler

Handler, Server current event processing interface object

1
Handler HttpsServer.handler;

Member function

enableCrossOrigin

Allow cross-domain requests

1
HttpsServer.enableCrossOrigin(String allowHeaders = "Content-Type");

Call parameters:

  • allowHeaders: String, specified to accept http Header field

start

Start the current server

1
HttpsServer.start();

stop

Close the socket to terminate the running server

1
HttpsServer.stop() async;

toString

Returns the string representation of the object, generally returns "[Native Object]", the object can be re-implemented according to its own characteristics

1
String HttpsServer.toString();

Return result:

  • String, Returns the string representation of the object

toJSON

Returns the JSON format representation of the object, generally returns a collection of readable attributes defined by the object

1
Value HttpsServer.toJSON(String key = "");

Call parameters:

  • key: String, unused

Return result:

  • Value, Returns a value containing JSON serializable