Resource interpreted as Script but transferred with MIME type application/dart

309 Views Asked by At

I am sending a Dart file via HttpServer, but whenever I get it, Chrome says:

"Resource interpreted as Script but transferred with MIME type application/dart: "http://localhost:8000/dart/game.dart"."

The line for the client is:

<script type="application/dart" src="dart/game.dart"></script>

And the line to give the file is:

if(new RegExp("/dart/(.*)").hasMatch(uri)){
    new File("static/" + uri.substring(1)).exists().then((bool exists){
      if(!exists) return;
        new File("static/" + uri.substring(1)).readAsString().then((String contents){
          if(uri.substring(uri.length - 2, uri.length) == "js")
            request.response.headers.contentType = new ContentType("application", "javascript", charset: "utf-8");
          else
            request.response.headers.contentType = new ContentType("application", "dart");

          request.response.write(contents);
          request.response.close();
      });
    });
  }

When I go directly to the URL, it gives me my file; and Google Chrome networking says this:

Remote Address:127.0.0.1:8000
Request URL:http://localhost:8000/dart/game.dart
Request Method:GET
Status Code:200 OK
Request Headersview source
Accept:*/*
Accept-Encoding:gzip, deflate, sdch
Accept-Language:en-US,en;q=0.8
Cache-Control:max-age=0
Connection:keep-alive
Host:localhost:8000
Referer:http://localhost:8000/play
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36
Response Headersview source
content-type:application/dart
transfer-encoding:chunked
x-content-type-options:nosniff
x-frame-options:SAMEORIGIN
x-xss-protection:1; mode=block

What can I do?

0

There are 0 best solutions below