Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[api]SPDY support via node-spdy

  • Loading branch information...
commit 23c1ca9c090dabe5f8a85c1e14a0df90a1d1706c 1 parent d57d3ea
Paweł Krefta pkrefta authored

Showing 1 changed file with 28 additions and 8 deletions. Show diff stats Hide diff stats

  1. +28 8 lib/core.js
36 lib/core.js
... ... @@ -1,5 +1,5 @@
1 1 /*
2   - * core.js: Core functionality for the Flatiron HTTP plugin.
  2 + * core.js: Core functionality for the Flatiron HTTP (with SPDY support) plugin.
3 3 *
4 4 * (C) 2011, Nodejitsu Inc.
5 5 * MIT LICENSE
@@ -50,18 +50,38 @@ core.createServer = function (options) {
50 50 req.pipe(routingStream);
51 51 }
52 52
53   - if (options.https) {
54   - if (!options.https.key || !options.https.cert) {
55   - throw new Error('Both `options.https.key` and `options.https.cert` are required.');
  53 + //
  54 + // both https and spdy requires same params
  55 + //
  56 + if (options.https || options.spdy) {
  57 +
  58 + var key;
  59 +
  60 + if(options.spdy) {
  61 + key = 'spdy';
  62 + } else {
  63 + key = 'https';
  64 + }
  65 +
  66 + server_options = options[key];
  67 +
  68 + if (!server_options.key || !server_options.cert) {
  69 + throw new Error('Both options.'+key+'.`key` and options.'+key+'.`cert` are required.');
56 70 }
57 71
58 72 credentials = {
59   - key: fs.readFileSync(options.https.key),
60   - cert: fs.readFileSync(options.https.cert)
  73 + key: fs.readFileSync(server_options.key),
  74 + cert: fs.readFileSync(server_options.cert)
61 75 };
62 76
63   - if (options.https.ca) {
64   - credentials.ca = fs.readFileSync(options.https.ca);
  77 + if (server_options.ca) {
  78 + credentials.ca = fs.readFileSync(server_options.ca);
  79 + }
  80 +
  81 + if(options.spdy){
  82 + // spdy is optional so we require module here rather than on top
  83 + var spdy = require('spdy');
  84 + return spdy.createServer(credentials, requestHandler);
65 85 }
66 86
67 87 return https.createServer(credentials, requestHandler);

0 comments on commit 23c1ca9

Please sign in to comment.
Something went wrong with that request. Please try again.