Object built-in object

Object HttpsServer

https server object

The https server object is an object that combines SslServer and HttpHandler , which is convenient to quickly build a server, and 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

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, used 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, used 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;

serverName

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

1
String HttpsServer.serverName;

socket

Socket , the Socket object currently listening by the server

1
readonly Socket HttpsServer.socket;

handler

Handler , the server's 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, specify the accepted http header fields

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