node-http-server – Diff between revs 29 and 30
?pathlinks?
Rev 29 | Rev 30 | |||
---|---|---|---|---|
Line 92... | Line 92... | |||
92 | |
92 | |
|
93 | // Start HTTP server. |
93 | // Start HTTP server. |
|
94 | http.createServer( |
94 | http.createServer( |
|
95 | // authentication, |
95 | // authentication, |
|
96 | (request, response) => |
96 | (request, response) => |
|
Line 97... | Line 97... | |||
97 | handler.process(config, request, response, root, (result) => { |
97 | handler.process(config, request, response, root, (logging, result) => { |
|
98 | |
98 | |
|
99 | // Log the message by severity. |
- | ||
100 | log.log(result.severity, result.message); |
- | ||
Line 101... | Line -... | |||
101 | if(result.status) |
- | ||
102 | response.status = result.status; |
99 | // Log the message by severity. |
|
103 | |
- | ||
104 | // If no data stream is made available or the content type is not |
100 | log.log(logging.severity, logging.message); |
|
105 | // set then there is no further reason to bother with the request. |
101 | |
|
Line -... | Line 102... | |||
- | 102 | // If no result is to be processed, then terminate the request. |
||
- | 103 | if (typeof result === 'undefined' || result === null) |
||
106 | if(typeof result.data === 'undefined' || result.data === null || |
104 | return; |
|
107 | typeof result.type === 'undefined' || result.type === null) |
105 | |
|
108 | return; |
106 | // Set the response status. |
|
109 | |
107 | response.status = result.status; |
|
110 | // Set the content type and send the data. |
- | ||
- | 108 | // Set the content type and send the data. |
||
111 | response.setHeader('Content-Type', result.type); |
109 | response.setHeader('Content-Type', result.type); |
|
112 | result.data |
110 | result.data |
|
113 | .on('open', () => result.data.pipe(response)); |
111 | .on('readable', () => result.data.pipe(response)) |
|
114 | |
112 | .on('end', () => response.end()); |
|
115 | }) |
113 | }) |
|
Line 138... | Line 136... | |||
138 | cert: certificates.certificate, |
136 | cert: certificates.certificate, |
|
139 | }, |
137 | }, |
|
140 | (request, response) => |
138 | (request, response) => |
|
141 | handler.process(config, request, response, root, (result) => { |
139 | handler.process(config, request, response, root, (result) => { |
|
142 | // Log the message by severity. |
140 | // Log the message by severity. |
|
143 | log.log(result.severity, result.message); |
141 | log.log(logging.severity, logging.message); |
|
144 | if(result.status) |
- | ||
145 | response.status = result.status; |
- | ||
Line 146... | Line -... | |||
146 | |
- | ||
147 | // If no data stream is made available or the content type is not |
142 | |
|
148 | // set then there is no further reason to bother with the request. |
- | ||
149 | if(typeof result.data === 'undefined' || result.data === null || |
143 | // If no result is to be processed, then terminate the request. |
|
150 | typeof result.type === 'undefined' || result.type === null) |
144 | if (typeof result === 'undefined' || result === null) |
|
Line -... | Line 145... | |||
- | 145 | return; |
||
- | 146 | |
||
151 | return; |
147 | // Set the response status. |
|
152 | |
148 | response.status = result.status; |
|
153 | // Set the content type and send the data. |
149 | // Set the content type and send the data. |
|
154 | response.setHeader('Content-Type', result.type); |
150 | response.setHeader('Content-Type', result.type); |
|
- | 151 | result.data |
||
155 | result.data |
152 | .on('readable', () => result.data.pipe(response)) |
|
156 | .on('open', () => result.data.pipe(response)); |
153 | .on('end', () => response.end()); |
|
157 | }) |
154 | }) |
|
158 | ).listen(config.ssl.port, config.ssl.address, () => { |
155 | ).listen(config.ssl.port, config.ssl.address, () => { |
|
159 | log.info('HTTPs Server accessible at: https://' + |
156 | log.info('HTTPs Server accessible at: https://' + |