I have a DataSnap server that serves templates (html) and resources (js, css) and then the browser accesses my serverfunctions from JavaScript. Straight from the (REST) wizard, you could say.

I have a DataSnap server that serves templates (html) and resources (js, css) and then the browser accesses my serverfunctions from JavaScript. Straight from the (REST) wizard, you could say.

I found out that Chrome (and only Chrome) hangs when resources are encoded differently. Sometimes it hangs on first load but the problem is reproducible when pressing the reload button:

http://stackoverflow.com/questions/3467404/chrome-says-resource-interpreted-as-script-but-transferred-with-mime-type-text and look at dandan78's answer a bit down.

I absolutely need the html to be encoded in ISO-8899-1 (it's a requirement) so i went and recoded everything in the subdirectories. Then i added this:

procedure TWebModule.WebModuleAfterDispatch(Sender: TObject; Request: TWebRequest;
  Response: TWebResponse; var Handled: Boolean);
begin
  if (Response.ContentType = 'text/javascript') or
     (Response.ContentType = 'text/css') then
    Response.ContentEncoding := 'iso-8859-1';
end;

and turned off KeepAlive (dunno if that is strictly necessary) and finally the site works a treat!

The problem now is i'm too stupid to figure out how to make the TDSProxyGenerator write using ANSI (at least not using UTF-8). I don't want to add extra instructions for server deployment nor do i like to distribute a "fixed" serverfunctions.js file.

I could recode the file after it's been written in WebFileDispatcherBeforeDispatch but that seems like a workaround since the generator has a WriterProperties property with a DefaultEncoding property.

What am i missing?

Thank you so much,

/Dany
http://stackoverflow.com/questions/3467404/chrome-says-resource-interpreted-as-script-but-transferred-with-mime-type-text

Comments