[Groonga-commit] groonga/gcs [master] Remove codes around "base host" completely

アーカイブの一覧に戻る

YUKI Hiroshi null+****@clear*****
Tue Dec 4 16:10:51 JST 2012


YUKI Hiroshi	2012-12-04 16:10:51 +0900 (Tue, 04 Dec 2012)

  New Revision: 44740423ffc907180c585735c2ed548dcefc8be8
  https://github.com/groonga/gcs/commit/44740423ffc907180c585735c2ed548dcefc8be8

  Log:
    Remove codes around "base host" completely

  Modified files:
    bin/gcs
    lib/api/2011-02-01/configuration.js
    lib/command-line.js
    packages/debian/gcs.default
    packages/debian/gcs.init
    packages/debian/gcs.upstart
    test/api-configuration.test.js
    test/test-utils.js

  Modified: bin/gcs (+0 -7)
===================================================================
--- bin/gcs    2012-12-04 15:44:35 +0900 (be13cda)
+++ bin/gcs    2012-12-04 16:10:51 +0900 (6c90e5f)
@@ -11,12 +11,6 @@ commandLine
             '[' + CLI.defaultDatabasePath + ']',
           String,
           CLI.defaultDatabasePath)
-  .option('--base-host <hostname>',
-          'The base host name assigned to the service ' +
-            '(GCS_BASE_HOST) ' +
-            '[' + CLI.defaultBaseHost + ']',
-          String,
-          CLI.defaultBaseHost)
   .option('-p, --port <port>',
           'The port number assigned to the service' +
             '(GCS_PORT) ' +
@@ -56,7 +50,6 @@ var server = gcsServer.createServer({
       errorLogPath:      commandLine.options.errorLogPath,
       privilegedRanges:  commandLine.options.privilege,
       port:              commandLine.port,
-      baseHost:          commandLine.baseHost,
       configurationHost: commandLine.options.configurationHost
     });
 

  Modified: lib/api/2011-02-01/configuration.js (+6 -32)
===================================================================
--- lib/api/2011-02-01/configuration.js    2012-12-04 15:44:35 +0900 (92a977c)
+++ lib/api/2011-02-01/configuration.js    2012-12-04 16:10:51 +0900 (98287e8)
@@ -93,28 +93,6 @@ function createSenderErrorResponse(errorCode, error, requestId) {
 
 var handlers = Object.create(null);
 
-var defaultHttpPort = 80;
-var defaultBaseHost = '127.0.0.1.xip.io';
-
-function getBaseHostAndPort(config, request) {
-  var host = config.baseHost ||
-             request.headers.http_x_forwarded_host ||
-             request.headers.host ||
-             defaultBaseHost + ':' + config.port;
-  var port = defaultHttpPort;
-
-  var portMatching = host.match(/:(\d+)$/);
-  if (portMatching) {
-    host = host.replace(portMatching[0], '');
-    port = parseInt(portMatching[1]);
-  }
-
-  if (port == defaultHttpPort)
-    return host;
-  else
-    return host + ':' + port;
-}
-
 function createGenericResponse(action, result, requestId) {
   var doc = xmlbuilder.create();
   var root = doc.begin(action + 'Response', { version: '1.0' })
@@ -168,8 +146,7 @@ handlers.CreateDomain = function(context, request, response, config) {
       });
   domain.saveSync();
   var result = createDomainStatus({
-        domain:      domain,
-        hostAndPort: getBaseHostAndPort(config, request)
+        domain: domain
       });
   response.contentType('application/xml');
   response.send(createGenericResponse('CreateDomain', result, request.id));
@@ -183,9 +160,8 @@ handlers.DeleteDomain = function(context, request, response, config) {
   if (domain.exists()) {
     domain.deleteSync();
     result = createDomainStatus({
-      domain:      domain,
-      hostAndPort: getBaseHostAndPort(config, request),
-      deleted:     true
+      domain:  domain,
+      deleted: true
     });
   } else {
     result = null;
@@ -199,9 +175,8 @@ function createDomainStatusList(options) {
   var domainStatusList = doc.begin('DomainStatusList', {version: '1.0'});
   options.domains.forEach(function(domain) {
     domainStatusList.importXMLBuilder(createDomainStatus({
-                       domain:      domain,
-                       hostAndPort: options.hostAndPort,
-                       element:     'member'
+                       domain:  domain,
+                       element: 'member'
                      }));
   });
   return doc;
@@ -234,8 +209,7 @@ handlers.DescribeDomains = function(context, request, response, config) {
                   }) :
                   Domain.getAll(context).reverse();
   var result = createDomainStatusList({
-        domains:     domains,
-        hostAndPort: getBaseHostAndPort(config, request)
+        domains: domains
       });
   response.contentType('application/xml');
   response.send(createGenericResponse('DescribeDomains', result, request.id));

  Modified: lib/command-line.js (+3 -10)
===================================================================
--- lib/command-line.js    2012-12-04 15:44:35 +0900 (3562f79)
+++ lib/command-line.js    2012-12-04 16:10:51 +0900 (6c558f4)
@@ -17,14 +17,10 @@ var defaultErrorLogPath =
 var defaultPort =
       exports.defaultPort =
       CommandLineInterface.defaultPort = process.env.GCS_PORT || 7575;
-var defaultBaseHost =
-      exports.defaultBaseHost =
-      CommandLineInterface.defaultBaseHost =
-        process.env.GCS_BASE_HOST || '127.0.0.1.xip.io:' + defaultPort;
 var defaultEndpoint =
       exports.defaultEndpoint =
       CommandLineInterface.defaultEndpoint =
-        defaultBaseHost;
+        '127.0.0.1.xip.io:' + defaultPort;
 var defaultPrivilegedRanges =
       exports.defaultPrivilegedRanges =
       CommandLineInterface.defaultPrivilegedRanges =
@@ -41,16 +37,13 @@ CommandLineInterface.prototype = {
     return this.options.domainName;
   },
   get host() {
-    return (this.options.baseHost || this.options.endpoint).split(':')[0];
+    return this.options.endpoint.split(':')[0];
   },
   get port() {
     return this.options.port ||
-           Number((this.options.baseHost || this.options.endpoint).split(':')[1] || 0) ||
+           Number(this.options.endpoint.split(':')[1] || 0) ||
            defaultPort;
   },
-  get baseHost() {
-    return this.host + ':' + this.port;
-  },
 
   get accessKeyId() {
     return this.options.accessKeyId ||

  Modified: packages/debian/gcs.default (+0 -6)
===================================================================
--- packages/debian/gcs.default    2012-12-04 15:44:35 +0900 (9a1745d)
+++ packages/debian/gcs.default    2012-12-04 16:10:51 +0900 (10683f1)
@@ -19,12 +19,6 @@ GCS_ERROR_LOG_PATH=/var/log/gcs/error.log
 # The port number to listen
 GCS_PORT=7575
 
-# The base host and port of endpoints returned as a part of DomainStatus.
-# For example, if you set as "GCS_BASE_HOST=example.com:7575", then the
-# document endpoint of a domain named "mysearchdomain" will be returned like:
-#   "doc-mysearchdomain-xxxxxx.example.com:7575"
-#GCS_BASE_HOST=127.0.0.1.xip.io:7575
-
 # Privileged IP range for the configuration API. Any request from out of
 # the range is denied.
 # You can specify multiple ranges as comma-separated list like:

  Modified: packages/debian/gcs.init (+0 -1)
===================================================================
--- packages/debian/gcs.init    2012-12-04 15:44:35 +0900 (fe4c1fd)
+++ packages/debian/gcs.init    2012-12-04 16:10:51 +0900 (86cbe5e)
@@ -46,7 +46,6 @@ export GCS_ACCESS_LOG_PATH
 export GCS_QUERY_LOG_PATH
 export GCS_ERROR_LOG_PATH
 export GCS_PORT
-export GCS_BASE_HOST
 export GCS_PRIVILEGED_RANGES
 
 [ "$ENABLE" = "yes" ] || exit 0

  Modified: packages/debian/gcs.upstart (+0 -1)
===================================================================
--- packages/debian/gcs.upstart    2012-12-04 15:44:35 +0900 (118b594)
+++ packages/debian/gcs.upstart    2012-12-04 16:10:51 +0900 (8eedc12)
@@ -20,7 +20,6 @@ script
   export GCS_QUERY_LOG_PATH
   export GCS_ERROR_LOG_PATH
   export GCS_PORT
-  export GCS_BASE_HOST
   export GCS_PRIVILEGED_RANGES
 
   exec /usr/sbin/gcs

  Modified: test/api-configuration.test.js (+0 -107)
===================================================================
--- test/api-configuration.test.js    2012-12-04 15:44:35 +0900 (3b6fe80)
+++ test/api-configuration.test.js    2012-12-04 16:10:51 +0900 (cffb747)
@@ -90,113 +90,6 @@ suite('Configuration API', function() {
     });
   });
 
-  suite('auto detection of the base hostname and port', function() {
-    setup(function() {
-      temporaryDatabase = utils.createTemporaryDatabase();
-      context = temporaryDatabase.get();
-    });
-
-    teardown(commonTeardown);
-
-    function assertBaseHost(baseHost, response) {
-      response = xmlResponses.toParsedResponse(response);
-      assert.deepEqual(response.pattern,
-                       { statusCode: 200,
-                         body: xmlResponses.CreateDomainResponse });
-      var domain = new Domain('companies', context);
-      var status = response.body.CreateDomainResponse.CreateDomainResult.DomainStatus;
-      assert.deepEqual(
-        { documentsEndpoint: status.DocService.Arn,
-          searchEndpoint:    status.SearchService.Arn },
-        { documentsEndpoint: domain.documentsArn,
-          searchEndpoint:    domain.searchArn }
-      );
-    }
-
-    test('specified by server option', function(done) {
-      var baseHost = 'by.server.option';
-      server = utils.setupServer(context, { baseHost: baseHost });
-      utils
-        .get('/?DomainName=companies&Action=CreateDomain&Version=2011-02-01')
-        .next(function(response) {
-          assertBaseHost(baseHost, response);
-          done();
-        })
-        .error(function(error) {
-          done(error);
-        });
-    });
-
-    test('specified by Host header', function(done) {
-      var baseHost = 'by.host.header';
-      server = utils.setupServer(context);
-      utils
-        .get('/?DomainName=companies&Action=CreateDomain&Version=2011-02-01', {
-          'Host': baseHost
-        })
-        .next(function(response) {
-          assertBaseHost(baseHost, response);
-          done();
-        })
-        .error(function(error) {
-          done(error);
-        });
-    });
-
-    test('specified by HTTP_X_FORWARDED_HOST header', function(done) {
-      var baseHost = 'by.forwarded.host.header';
-      server = utils.setupServer(context);
-      utils
-        .get('/?DomainName=companies&Action=CreateDomain&Version=2011-02-01', {
-          'HTTP_X_FORWARDED_HOST': baseHost
-        })
-        .next(function(response) {
-          assertBaseHost(baseHost, response);
-          done();
-        })
-        .error(function(error) {
-          done(error);
-        });
-    });
-
-    test('HTTP_X_FORWARDED_HOST and Host header', function(done) {
-      var baseHost =          'by.host.header';
-      var baseHostForwarded = 'by.forwarded.host.header';
-      server = utils.setupServer(context);
-      utils
-        .get('/?DomainName=companies&Action=CreateDomain&Version=2011-02-01', {
-          'Host': baseHost,
-          'HTTP_X_FORWARDED_HOST': baseHostForwarded
-        })
-        .next(function(response) {
-          assertBaseHost(baseHostForwarded, response);
-          done();
-        })
-        .error(function(error) {
-          done(error);
-        });
-    });
-
-    test('HTTP_X_FORWARDED_HOST, Host header, and server option', function(done) {
-      var baseHostByOption =  'by.server.option';
-      var baseHost =          'by.host.header';
-      var baseHostForwarded = 'by.forwarded.host.header';
-      server = utils.setupServer(context, { baseHost: baseHostByOption });
-      utils
-        .get('/?DomainName=companies&Action=CreateDomain&Version=2011-02-01', {
-          'Host': baseHost,
-          'HTTP_X_FORWARDED_HOST': baseHostForwarded
-        })
-        .next(function(response) {
-          assertBaseHost(baseHostByOption, response);
-          done();
-        })
-        .error(function(error) {
-          done(error);
-        });
-    });
-  });
-
   suite('Action=DefineIndexField', function() {
     setup(commonSetup);
     teardown(commonTeardown);

  Modified: test/test-utils.js (+0 -2)
===================================================================
--- test/test-utils.js    2012-12-04 15:44:35 +0900 (00bdc68)
+++ test/test-utils.js    2012-12-04 16:10:51 +0900 (2e272e5)
@@ -12,10 +12,8 @@ var url = require('url');
 
 var temporaryDirectory = exports.temporaryDirectory = path.join(__dirname, 'tmp');
 
-var testBaseHost = 'api.localhost';
 var testConfigurationHost = 'configuration.localhost';
 var testPort = 3333;
-exports.testBaseHost = testBaseHost;
 exports.testConfigurationHost = testConfigurationHost;
 exports.testPort = testPort;
 
-------------- next part --------------
HTML����������������������������...
ダウンロード 



More information about the Groonga-commit mailing list
アーカイブの一覧に戻る