Karma: Karma middleware causing bug for non-english windows environment (The header content contains invalid characters)

Created on 17 Mar 2016  路  3Comments  路  Source: karma-runner/karma

Expected behavior

tests are good

Actual behavior

exit and throw Fatal error: The header content contains invalid characters

Enviroment Details

windows 7 x64 non-english (important), nodeJs 5.9.0 / 4.3.1

looks like Date.toString issue for non-english Windows

  • Karma version (output of karma --version): 0.12.37
  • Relevant part of your karma.config.js file
    preprocessors: { 'js/build/*.js': ['coverage'] }, coverageReporter: { type: 'html', dir: '_dev/coverage/' }, plugins:[ 'karma-qunit', 'karma-coverage', 'karma-phantomjs-launcher', 'karma-chrome-launcher' ], port: 9879, colors: true, logLevel: config.LOG_DEBUG, autoWatch: false, browsers: ['PhantomJS', /*'Chrome', 'Firefox', 'Safari'*/],

Steps to reproduce the behaviour

  1. run test
  2. fail

these issues:

are connected

I've found that common.js in karma middleware contains a function setNoCacheHeaders, which relies on Date.toString to set 'expires' header

response.setHeader('Expires', (new Date(0)).toString())

, which is failing, when the result of toString is something like (notice cyrillic)

"Thu Jan 01 1970 03:00:00 GMT+0300 (RTZ 2 (蟹懈屑邪))"

setHeader cannot process the output of toString because it's not RFC 1123 date string maybe

I may address this issue to wrong repo, please correct me.
http://i.imgur.com/bfcX5Ph.jpg

(the picture shows an output of .toString call containing Cyrillic characters

Most helpful comment

This was already fixed in https://github.com/karma-runner/karma/pull/1884 as far as I understand. New release will come soon.

All 3 comments

toString() may be replaced with toUTCString() which is RFC1123 compliant

This was already fixed in https://github.com/karma-runner/karma/pull/1884 as far as I understand. New release will come soon.

@dignifiedquire perfect, thank you

Was this page helpful?
0 / 5 - 0 ratings

Related issues

macjohnny picture macjohnny  路  5Comments

mgol picture mgol  路  3Comments

TKTheTechie picture TKTheTechie  路  4Comments

IgorMinar picture IgorMinar  路  5Comments

mboughaba picture mboughaba  路  3Comments