Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.charset(charset) doesn't work on its own in ext #2979

Closed
rockbot opened this issue Dec 17, 2015 · 7 comments
Closed

.charset(charset) doesn't work on its own in ext #2979

rockbot opened this issue Dec 17, 2015 · 7 comments
Assignees
Labels
Milestone

Comments

@rockbot
Copy link

@rockbot rockbot commented Dec 17, 2015

Desired header: content-type: text/html; charset=utf-8

However:

  server.ext('onPreResponse', function(request, reply) {
    request.response.charset('utf-8');

    return reply.continue();
  });

results in the following header: content-type: text/html. (text/html is the default content-type header)

The current workaround is to use

  server.ext('onPreResponse', function(request, reply) {
    request.response.type('text/html').charset('utf-8');

    return reply.continue();
  });

which results in the desired behavior.

@hueniverse hueniverse added the bug label Dec 17, 2015
@hueniverse hueniverse changed the title .charset(charset) doesn't work on its own .charset(charset) doesn't work on its own in ext Dec 27, 2015
@hueniverse
Copy link
Contributor

@hueniverse hueniverse commented Dec 27, 2015

I can't reproduce this (see test). Can you tell me more about the response? What is it? where is it coming from? Maybe a console.log(request.response)?

@hueniverse hueniverse self-assigned this Dec 27, 2015
hueniverse added a commit that referenced this issue Dec 27, 2015
@rockbot
Copy link
Author

@rockbot rockbot commented Jan 4, 2016

here's the way we're using it on the site, which may be able to help: https://github.com/npm/newww/blob/6e633e11cf6a453db79bc9beaa64f230703f591f/adapters/bonbon.js#L108-L109

@rockbot
Copy link
Author

@rockbot rockbot commented Jan 5, 2016

here's request.response:

EventEmitter {
  domain:
   Domain {
     domain: null,
     _events: { error: [Function] },
     _eventsCount: 1,
     _maxListeners: undefined,
     members: [] },
  _events: {},
  _eventsCount: 0,
  _maxListeners: undefined,
  request:
   EventEmitter {
     domain:
      Domain {
        domain: null,
        _events: [Object],
        _eventsCount: 1,
        _maxListeners: undefined,
        members: [] },
     _events: {},
     _eventsCount: 0,
     _maxListeners: undefined,
     _bench: { ts: 269322030.269452 },
     connection:
      EventEmitter {
        domain: null,
        _events: [Object],
        _eventsCount: 5,
        _maxListeners: undefined,
        settings: [Object],
        server: [Object],
        type: 'tcp',
        _started: true,
        _connections: [Object],
        _onConnection: [Function],
        registrations: [Object],
        _extensions: [Object],
        _requestCounter: [Object],
        _load: [Object],
        states: [Object],
        auth: [Object],
        _router: [Object],
        plugins: {},
        app: {},
        listener: [Object],
        info: [Object] },
     server:
      EventEmitter {
        _settings: [Object],
        _caches: [Object],
        _handlers: [Object],
        _methods: [Object],
        _events: [Object],
        _dependencies: [Object],
        _registrations: [Object],
        _heavy: [Object],
        _mime: [Object],
        _replier: [Object],
        _requestor: [Object],
        _decorations: [Object],
        _plugins: [Object],
        _app: [Object],
        _registring: false,
        _state: 'started',
        _extensionsSeq: 21,
        _extensions: [Object],
        domain: null,
        _maxListeners: undefined,
        _sources: [Object],
        _parent: null,
        root: [Circular],
        app: [Object],
        connections: [Object],
        load: [Object],
        methods: [Object],
        mime: [Object],
        plugins: [Object],
        settings: [Object],
        version: '11.1.2',
        realm: [Object],
        auth: [Object],
        info: [Object],
        listener: [Object],
        registrations: [Object],
        stamp: 'pid=29094 35ca8277aebab542ee8e577cf570bfe3efebcb5e http://localhost:15443 rosie.local ',
        gitHead: '35ca8277aebab542ee8e577cf570bfe3efebcb5e',
        views: [Function],
        render: [Function] },
     url:
      Url {
        protocol: null,
        slashes: null,
        auth: null,
        host: null,
        port: null,
        hostname: null,
        hash: null,
        search: null,
        query: {},
        pathname: '/',
        path: '/',
        href: '/' },
     query: {},
     path: '/',
     method: 'get',
     mime: null,
     setUrl: undefined,
     setMethod: undefined,
     headers:
      { host: 'localhost:15443',
        accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
        connection: 'keep-alive',
        cookie: '__hssrc=1; __hstc=181257784.6748da560b6effaacbfa27d8c35c6ca3.1432149825041.1450306419070.1450388488874.226; _ga=GA1.1.171521356.1416617315; crumb=5RbUn1ZUc4M_-srpFxkgrLOepfQZSU0J3ZlRBqnyGh7; hsfirstvisit=https%3A%2F%2Flocalhost%3A15443%2F||1432149825040; hubspotutk=6748da560b6effaacbfa27d8c35c6ca3; optimizelyBuckets=%7B%7D; optimizelyEndUserId=oeu1447869409699r0.6300706123001873; optimizelySegments=%7B%223318760495%22%3A%22false%22%2C%223320910574%22%3A%22direct%22%2C%223324110209%22%3A%22safari%22%2C%223359291244%22%3A%22none%22%7D',
        'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_2) AppleWebKit/601.3.9 (KHTML, like Gecko) Version/9.0.2 Safari/601.3.9',
        'accept-language': 'en-us',
        dnt: '1',
        'accept-encoding': 'gzip, deflate' },
     id: '1451956569330:rosie.local:29094:ij0pen1u:10000',
     app: {},
     plugins:
      { scooter: [Object],
        crumb: '5RbUn1ZUc4M_-srpFxkgrLOepfQZSU0J3ZlRBqnyGh7' },
     _route:
      { settings: [Object],
        connection: [Object],
        server: [Object],
        path: '/',
        method: 'get',
        plugin: [Object],
        _special: false,
        _analysis: [Object],
        params: [],
        fingerprint: '/',
        public: [Object],
        _prerequisites: null,
        _extensions: [Object],
        _cycle: [Object] },
     route:
      { method: 'get',
        path: '/',
        vhost: undefined,
        realm: [Object],
        settings: [Object],
        fingerprint: '/' },
     auth:
      { isAuthenticated: false,
        credentials: null,
        artifacts: null,
        session: [Object],
        mode: 'try',
        error: [Object] },
     session: null,
     pre: {},
     preResponses: {},
     info:
      { received: 1451956569330,
        responded: 0,
        remoteAddress: '127.0.0.1',
        remotePort: 51548,
        referrer: '',
        host: 'localhost:15443',
        acceptEncoding: 'gzip',
        hostname: 'localhost' },
     orig: {},
     params: {},
     paramsArray: [],
     payload: null,
     state:
      { __hssrc: '1',
        __hstc: '181257784.6748da560b6effaacbfa27d8c35c6ca3.1432149825041.1450306419070.1450388488874.226',
        _ga: 'GA1.1.171521356.1416617315',
        crumb: '5RbUn1ZUc4M_-srpFxkgrLOepfQZSU0J3ZlRBqnyGh7',
        hsfirstvisit: 'https%3A%2F%2Flocalhost%3A15443%2F||1432149825040',
        hubspotutk: '6748da560b6effaacbfa27d8c35c6ca3',
        optimizelyBuckets: '%7B%7D',
        optimizelyEndUserId: 'oeu1447869409699r0.6300706123001873',
        optimizelySegments: '%7B%223318760495%22%3A%22false%22%2C%223320910574%22%3A%22direct%22%2C%223324110209%22%3A%22safari%22%2C%223359291244%22%3A%22none%22%7D' },
     jsonp: null,
     response: [Circular],
     raw: { req: [Object], res: [Object] },
     addTail: [Function],
     tail: [Function],
     _states: {},
     _logger: [ [Object], [Object], [Object], [Object] ],
     _allowInternals: false,
     _isPayloadPending: true,
     _isBailed: false,
     _isReplied: true,
     _isFinalized: false,
     _tails: {},
     _tailIds: 0,
     _protect: { _error: [Function], logger: [Circular], domain: [Object] },
     _onEnd: [Function],
     _onClose: [Function],
     _onError: [Function],
     render: [Function],
     metrics: StubMetricsEmitter {},
     redis:
      RedisClient {
        stream: [Object],
        connection_id: 1,
        connected: true,
        ready: true,
        connections: 1,
        should_buffer: false,
        command_queue_high_water: 1000,
        command_queue_low_water: 0,
        max_attempts: 0,
        command_queue: [Object],
        offline_queue: [Object],
        connect_timeout: 86400000,
        enable_offline_queue: true,
        retry_max_delay: null,
        retry_timer: null,
        retry_totaltime: 0,
        retry_delay: 200,
        retry_backoff: 1.7,
        attempts: 1,
        pub_sub_mode: false,
        subscription_set: {},
        monitoring: false,
        closing: false,
        server_info: [Object],
        auth_pass: undefined,
        parser_module: [Object],
        selected_db: null,
        old_state: null,
        options: [Object],
        domain: null,
        _events: [Object],
        _eventsCount: 1,
        _maxListeners: undefined,
        connectionOption: [Object],
        address: 'localhost:6379',
        emitted_end: false,
        reply_parser: [Object],
        send_anyway: false },
     logger:
      { [Function: boleLogger]
        debug: [Function],
        info: [Function],
        warn: [Function],
        error: [Function] },
     timing: { start: 1451956569343 },
     features: { access_page: true, billing_page: true, org_billing: true },
     saveNotifications: [Function] },
  statusCode: 200,
  headers: { 'Content-Security-Policy': 'connect-src \'self\' https://typeahead.npmjs.com/ https://partners.npmjs.com/ https://checkout.stripe.com/api/outer/manhattan https://api.github.com https://ac.cnstrc.com https://*.log.optimizely.com;default-src \'self\';font-src \'self\' https://fonts.gstatic.com https://assets.npmjs.com;frame-src https://checkout.stripe.com https://js.stripe.com https://www.youtube.com https://s3-us-west-2.amazonaws.com/files.accountdock.com/pre.prod.html https://accountdock.com/app https://assets.npmjs.com;img-src *;script-src \'self\' https://forms.hubspot.com/uploads/form/v2/419727/9a2b4ac5-ef09-43e6-854a-d82c92347c9d https://forms.hubspot.com/uploads/form/v2/419727/6672f0d7-d2df-4696-a164-a8fa139d8f15 https://forms.hubspot.com/uploads/form/v2/419727/64c6e95b-b2c7-4989-a8ae-d967645e5198 https://forms.hubspot.com/uploads/form/v2/419727/d9ba17d5-606e-456d-a703-733c67f5e708 https://js.hsforms.net/forms/current.js https://api.hubapi.com https://internal.hubapi.com https://js.hs-analytics.net https://img.en25.com/i/elqCfg.min.js https://api.stripe.com https://checkout.stripe.com/checkout.js https://js.stripe.com https://platform.twitter.com/oct.js https://www.google-analytics.com https://fonts.googleapis.com https://s3.amazonaws.com/downloads.mailchimp.com/js/mc-validate.js https://npmjs.us9.list-manage.com https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.2/html5shiv.min.js https://cdn.optimizely.com/js/3318080746.js https://cnstrc.com/js/ac.js https://ac.cnstrc.com https://static.accountdock.com/app.min.js https://assets.npmjs.com \'unsafe-eval\';style-src \'self\' \'unsafe-inline\' https://fonts.googleapis.com https://assets.npmjs.com;report-uri /-/csplog' },
  variety: 'view',
  app: {},
  plugins: {},
  send: null,
  hold: undefined,
  settings:
   { encoding: 'utf8',
     charset: 'utf-8',
     ttl: null,
     stringify: null,
     passThrough: true,
     varyEtag: false },
  _payload: null,
  _takeover: false,
  _contentEncoding: null,
  _error: null,
  _processors: { marshal: [Function], prepare: [Function], close: undefined },
  source:
   { manager: { _context: null, _engines: [Object], _defaultExtension: 'hbs' },
     template: 'homepage',
     context:
      { correlationID: '1451956569330:rosie.local:29094:ij0pen1u:10000',
        stamp: 'pid=29094 35ca8277aebab542ee8e577cf570bfe3efebcb5e http://localhost:15443 rosie.local ',
        features: [Object],
        devEnv: true,
        env: [Object],
        canonicalURL: 'http://localhost:15443/',
        explicit: [Object],
        modified: [Object],
        dependents: [Object],
        downloads: [Object],
        totalPackages: 161918,
        crumb: '5RbUn1ZUc4M_-srpFxkgrLOepfQZSU0J3ZlRBqnyGh7',
        user: undefined },
     options: undefined,
     compiled: { settings: [Object], template: [Function], layout: [Function] } } }

@kanongil
Copy link
Contributor

@kanongil kanongil commented Jan 5, 2016

hueniverse added a commit that referenced this issue Mar 10, 2016
@hueniverse
Copy link
Contributor

@hueniverse hueniverse commented Mar 10, 2016

@kanongil Take a look at the new test. I still cannot reproduce this.

@kanongil
Copy link
Contributor

@kanongil kanongil commented Mar 10, 2016

It fails if you change the generateResponse source option to an object instead of 'text', as it is applied in vision.

@hueniverse
Copy link
Contributor

@hueniverse hueniverse commented Mar 11, 2016

That is so odd. Stupid default types.

@hueniverse hueniverse added this to the 13.1.1 milestone Mar 11, 2016
@lock lock bot locked as resolved and limited conversation to collaborators Jan 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants