Git Product home page Git Product logo

Comments (6)

geoperez avatar geoperez commented on August 17, 2024

Hi Kim,

Let me take a look and probably setup the HttpListener thread with en-US
culture to avoid force it from outside.

Thank you

On Fri, Nov 27, 2015 at 1:21 AM, Sunghun Kim [email protected]
wrote:

I got ArgumentException with any http request, the stack trace is:

2015-11-27 16:08:16.704 System.ArgumentException: 지정한 값에 잘못된 제어 문자가 있습니다.
매개 변수 이름: value
위치: System.Net.WebHeaderCollection.CheckBadChars(String name, Boolean
isHeaderValue)
위치: System.Net.WebHeaderCollection.SetInternal(String name, String value)
위치: Unosquare.Labs.EmbedIO.Extensions.NoCache(HttpListenerContext context)
위치: Unosquare.Labs.EmbedIO.Modules.WebApiModule.<.ctor>b__2_0(WebServer
server, HttpListenerContext context)
위치: Unosquare.Labs.EmbedIO.WebServer.ProcessRequest(HttpListenerContext
context)

The cause is

context.Response.AddHeader(Constants.HeaderLastModified,
        DateTime.UtcNow.ToString(Constants.BrowserTimeFormat));

in Extensions.NoCache() method.

With Korean locale, ToString("ddd, dd MMM yyyy HH:mm:ss 'GMT'") generates
non-ASCII characters.
The token "ddd" is the problem.

Workaround: change the locale on program startup, like

var culture = CultureInfo.CreateSpecificCulture("en-US");
CultureInfo.DefaultThreadCurrentCulture = culture;
CultureInfo.DefaultThreadCurrentUICulture = culture;

I wish this problem is fixed for non-english users in the world~ :)


Reply to this email directly or view it on GitHub
#24.

Geo Pérez

from embedio.

geoperez avatar geoperez commented on August 17, 2024

@shkim quick question, what .NET version are you using?

from embedio.

shkim avatar shkim commented on August 17, 2024

Windows 8.1 / Visual Studio 2013 / .NET Framework 4.5.1

from embedio.

mariodivece avatar mariodivece commented on August 17, 2024

My suggestion is to generate the Browser Time Format manually as opposed to using a format string. The days of the week and the names of every month will need to be specified by a hard-coded dictionary using DateTime.DayOfWeek and DateTime.Month respectively as keys to what the browser expects.

from embedio.

mariodivece avatar mariodivece commented on August 17, 2024

I have updated the code to use en-US culture when generating these headers. Hope this fixes the issue.

from embedio.

mariodivece avatar mariodivece commented on August 17, 2024

@geoperez maybe add a unit test that creates a web server under a thread with a different culture and check if it generates the browser time format the right way.

Closing issue as not further comment were provided by @shkim

from embedio.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.