delphi(kylix)開發wap(wml)程序的配置攻略

delphi(kylix)開發wml程序的配置攻略

delphi(kylix)提供了websnap技術可以用來開發web程序,分析web程序與wap程序的差異在於內容的標籤不同,http流中的Content-Type不同。

http的Content-Type爲text/html

wap的Content-Type爲text/wml

以下例子在linux下的kylix環境中通過,delphi中與此相似.

1、首先下載HTTP協議調試器httpdebug.exe。檢查Content-Type的內容。爲text/html

r_http_d_html.JPG

2、分析websnap構成,在kylix安裝目錄下,以kylix3爲例,默認安裝目錄在/usr/local/kylix3下。

在/usr/local/kylix3/source/internet目錄下,執行

grep "text/html" * -ri

結果如下:

ApacheApp.pas: r.content_type := 'text/html';
ApacheHTTP.pas: ContentType := 'text/html';
二進制文件 CGIApp.dcu 匹配
CGIApp.pas: 'Content-Type: text/html'#13#10 + { do not localize }
二進制文件 CGIHTTP.dcu 匹配
CGIHTTP.pas: ContentType := 'text/html'; { do not localize }
CGIHTTP.pas: ContentType := 'text/html'; { do not localize }
DBAdaptImg.pas: Response.ContentType := 'text/html'; // for any exceptions that may happen
二進制文件 oxmldom.dcu 匹配
oxmldom.pas: IndyHttp.Request.Accept := 'text/xml, text/html, application/octet-stream'; { Do not localize }
SockHTTP.pas: ContentType := 'text/html'; {do not localize}
SockHTTP.pas: ContentType := 'text/html'; {do not localize}
SockHTTP.pas: 'Content-Type: text/html'#13#10 + //Not resourced
SvrHTTPIndy.pas: ContentType := 'text/html';
SvrHTTPIndy.pas: ContentType := 'text/html';

3、再看websnap模板中引入的頭文件與websnap相關,並且文件中含有text/html的文件一共有三個:

CGIApp.pas

CGIHTTP.pas

DBAdaptImg.pas

4、分別將三個文件,複製一份,名字前冠以Wap,並修改unit名稱與文件名一致,修改其中的text/html爲text/wml即可

(1)cp CGIApp.pas WapCGIApp.pas

vi WapCGIApp.pas

修改文件頭部的unit CGIApp爲unit WapCGIApp

替換其中的text/html爲text/wml

(2)cp CGIHTTP.pas WapCGIHTTP.pas

vi WapCGIHTTP.pas

修改文件頭部的unit CGIHTTP爲unit WapCGIHTTP

替換其中的text/html爲text/wml

(3)cp DBAdaptImg.pas WapDBAdaptImg.pas

vi WapDBAdaptImg.pas

修改文件頭部的unit DBAdaptImg爲unit WapDBAdaptImg

替換其中的text/html爲text/wml

5、編譯後,放到/usr/local/kylix3/lib目錄中

(1)dcc WapCGIApp.pas

dcc WapCGIHTTP.pas

dcc WapDBAdaptImg.pas

(2)cp Wap*.dcu /usr/local/kylix3

6、創建websnap應用程序後,將

uses中的CGIApp改爲WapCGIApp即可。

對於模塊中出現的相應CGIHTTP與DBAdaptImg處,也用WapCGIHTTP或WapDBAdaptImg替換即可。

將程序編譯。

r_websnap_replace_uses.JPG

7、用httpdebug檢查結果。

r_http_d_wml.JPG

?

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章