I am implementing an application using Delphi XE2 Rest/JSON Server and jQTouch client. I have pretty much finished the server side and am now moving onto the client side development.
I have downloaded the jQTouch source and have set it up under IIS on port 8081 of my PC. This works fine.
But I need the static demo source to be accessible via a Delphi WebFileDispatcher. This is where I have the problem...
As a stripped down test/proof, I have set this up using the Web Broker / Web Server Application / Standalone VCL wizard, and dropped a WebFileDispatcher onto the Web Module. The only config has been to configure the 'Root' of the WebFileDispatcher to pick up the content.
Here's the problem reproduced in its most simple form:
I can access the content via IIS on port 8081.
I can access the content via Web Broker on port 8080.
Both using exactly the same localhost URL, just different ports.
So I know my paths and basic config are correct.
BUT... the 'Greater Than' or 'Right Arrows' on the jQTouch menu items are appearing as an 'a' with a circumflex when the content is server up from Web Broker. The green external link arrows are appearing with a Euro symbol on them.
The content appears without any problem when server up from IIS.
The problem appears to be the charset that is being appended to the content-type by code in the IdHTTPHeaderInfo unit. This unit is adding 'charset=8859-1' when the html and css files are UTF-8.
I can fix this by changing the MimeTypes defined in the WebFileExtensions property of the WebFileDispatcher to include charset=UTF-8. i.e. change the entry for 'text/html' to 'text/html; charset=UTF-8'.
But should this be required? I don't think so. I think that either: A) If Delphi includes a web server that is serving these files and its default is to assume all text files are 8859-1, then the mime types of the web dispatcher should be setup to override this to the correct value of UTF-8. B) Or the files should be checked for head meta tags for the actual encoding to be reported in the response. At the moment, neither of these seem to be the case.
Would anybody else class this as a bug that needs reporting? It has taken two days to narrow the problem down this far, and I wouldn't want anyone else to have to do this in the future.
See W3.org - Handling Character Encodings
To reproduce, just download the latest jQTouch release and map the content to a WebFileDispatcher.
Here are two images that show the problem:
![enter image description here][2]
Also, below are the Delphi files relating to the configuration of the Web Module..
Here is the PAS file...
unit WebModuleUnit1;
interface
uses System.SysUtils, System.Classes, Web.HTTPApp;
type
TWebModule1 = class(TWebModule)
WebFileDispatcher1: TWebFileDispatcher;
procedure WebModule1DefaultHandlerAction(Sender: TObject;
Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
private
{ Private declarations }
public
{ Public declarations }
end;
var
WebModuleClass: TComponentClass = TWebModule1;
implementation
{$R *.dfm}
procedure TWebModule1.WebModule1DefaultHandlerAction(Sender: TObject;
Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
begin
Response.Content := '<html><heading/><body>Web Server Application</body></html>';
end;
end.
And here is the dfm...
object WebModule1: TWebModule1
OldCreateOrder = False
Actions = <
item
Default = True
Name = 'DefaultHandler'
PathInfo = '/'
OnAction = WebModule1DefaultHandlerAction
end>
Height = 230
Width = 415
object WebFileDispatcher1: TWebFileDispatcher
WebFileExtensions = <
item
MimeType = 'text/css'
Extensions = 'css'
end
item
MimeType = 'text/html'
Extensions = 'html;htm'
end
item
MimeType = 'text/javascript'
Extensions = 'js'
end
item
MimeType = 'image/jpeg'
Extensions = 'jpeg;jpg'
end
item
MimeType = 'image/x-png'
Extensions = 'png'
end>
WebDirectories = <
item
DirectoryAction = dirInclude
DirectoryMask = '*'
end
item
DirectoryAction = dirExclude
DirectoryMask = '\templates\*'
end>
RootDirectory = 'C:\WebRoot'
Left = 80
Top = 64
end
end
[2]: