1

我已经在 Delphi7 中将 Indy9 升级到了 Indy10。我花了一些时间来更改 TCP 服务器和客户端的所有部分,但现在看起来效果很好。

现在,我注意到一部分仍然无法正常工作,那就是 idHTTPserver 组件。

我们的应用程序网页正在使用 mootools 库。使用 Indy9 idHTTPserver 它可以完美运行,但是 Indy10 做了一些事情,这使得浏览器无法显示页面。

除了一些其他错误之外,还有这个无意义的错误,例如(Firefox 错误控制台输出):

Timestamp: 2013.08.07 13:13:56
Error: SyntaxError: missing ] after element list
Source File: http://192.168.100.2:8780/lib/ui/core/mootools-1.2.4-more-yc.js
Line: 103, Column: 60
Source Code:
unction(){var b=["C?","C ","C","C?","C,","C¢","Cƒ","C£","C"","C¤","C.","C?","Ä,","ă","Ä"","Ä.","Ä?","Ä?","ÄŒ","Ĩ","C?
-------------------------------------------------------------^

这个 .js 中的实际源代码是:

long long text ....... function(){var b=["C?","C ","C","C?","C,","C¢","Cƒ","C£","C"","C¤","C.","C?","Ä,","ă","Ä"","Ä.","Ä?","Ä?","ÄŒ","Ĩ","C?","C§","Ä?","ĸ","Ä","Ä'","Cˆ","CØ","C?","C©","CŠ","CR","C<","C«","Äš","Ä>","Ę","ÄT","Ä?","ÄŸ","CŒ","C¬","C¨","C­","C?","C®","C¸","CÆ","Ĺ","Är","Ľ","ľ","Å","Å,","C'","C±","Å?","ň","Ń","Å"","C'","C²","C"","C³","C"","C´","C.","Cµ","C-","C¶","C˜","Cø","Å'","Ř","ÅT","Å"","Å.","Å ","Å?","Å?","ÅŸ","Åš","Å>","Ť","Å?","Ť","Å?","Å¢","Å£","CT","C¹","Cš","Cr","C>","C»","Cœ","C¼","Å®","ÅÆ","Åø","Cæ","C½","C¯","Ž","ž","Ź","År","Å»","ż","C?","C¾","C","C°","CŸ","Å'","Å"","C?","C¦","Aµ"]; ................ long long text

这里发生了什么?

我深吸一口气,想,嘿,我可以使用旧版本的 idHTTPserver,因为我在另一个文件夹中仍然有 Indy9 的源文件。如果没有人知道如何修复 indy10 HTTPserver,有人可以告诉我如何使用旧版本吗?只是 HTTPserver 组件(它肯定会与其他 10 多个旧的 indy 文件链接)。

我试图包含旧的来源,但它变得一团糟,因为它会使用旧版本中的 idHTTPserver.pas,而新版本中的 idCustomHTTPserver.pas(这是我遵循 idHTTPserver.pas 文件的使用后发生的情况) ...

4

2 回答 2

0

虽然这不是我自己的标题问题的直接答案,但这确实解决了我的问题。

跟着HTTPserver.WriteContent导入的函数idHTTPServer.pas,对比了Indy9和Indy10的idHTTPServer.pas文件,Indy10中关于编码的部分引起了我的注意。

在第 2039 行,我删除了 write 函数的第二个参数

FConnection.IOHandler.Write(ContentText, CharsetToEncoding(CharSet));
替换为 FConnection.IOHandler.Write(ContentText);

这解决了我的问题。现在一切正常。

正如评论者所注意到的那样,这里的主要问题是额外的“符号。我很愚蠢,因为我点击了firefox控制台中的链接,它打开了版本错误的javascript文件,出于某种原因,我认为这就是它应该是。不久之后,我决定检查我电脑上的实际文件,结果发现它"C""甚至不是 C,实际文本是这样的

var b=["À","à","Á","á","Â","â","Ã","ã","Ä","ä","Å","å","Ă","ă","Ą","ą","Ć","ć","Č","č","Ç","ç","Ď","ď","Đ","đ","È","è","É","é","Ê","ê","Ë","ë","Ě","ě","Ę","ę","Ğ","ğ","Ì","ì","Í","í","Î","î","Ï","ï","Ĺ","ĺ","Ľ","ľ","Ł","ł","Ñ","ñ","Ň","ň","Ń","ń","Ò","ò","Ó","ó","Ô","ô","Õ","õ","Ö","ö","Ø","ø","ő","Ř","ř","Ŕ","ŕ","Š","š","Ş","ş","Ś","ś","Ť","ť","Ť","ť","Ţ","ţ","Ù","ù","Ú","ú","Û","û","Ü","ü","Ů","ů","Ÿ","ÿ","ý","Ý","Ž","ž","Ź","ź","Ż","ż","Þ","þ","Ð","ð","ß","Œ","œ","Æ","æ","µ"];

所以,我是对的。当整个文本经过 CharsetToEncoding 时,它将所有这些单个符号字符转换为 2 个符号。

我不会接受我自己的答案,因为它并没有真正回答标题问题,我很想知道是否可以使用旧版本的单个组件,而其余的都是新的。

于 2013-08-08T05:16:09.970 回答
0

要在一个项目中使用不同的 Indy 版本,请将项目搜索路径设置为 Indy\Lib\Core、\Protocols 和 \System,并在代码中实例化所有组件。

这还有一个好处是可以避免在不同 Indy 10 版本之间切换的卸载/安装步骤。

于 2013-08-07T18:00:08.317 回答