用户端请求数据的代码如下:
procedure TForm1.ServerSocket1ClientRead(Sender: TObject;
Socket: TCustomWinSocket);
var
tmp,line,host:string;
i,j,port:integer;
begin
for i:=1 to sessions do
if session[i-1].Used and (session[i-1].SS_Handle=socket.sockethandle) then
begin
session[i-1].request_str:=socket.receivetext;
tmp:=session[i-1].request_str;
memo1.lines.add(tmp);
j:=pos(char(13)+char(10),tmp);
while j>0 do begin
line:=copy(tmp,1,j-1);
delete(tmp,1,j+1);
j:=pos('Host',line);
if j>0 then
begin
delete(line,1,j+5);
j:=pos(':',line);
if j>0 then
begin
host:=copy(line,1,j-1);
delete(line,1,j-1);
try
port:=strtoint(line);
except
port:=80
end;
end
else
begin
host:=trim(line);
port:=80;
end;
if not session[i-1].remote_connected then
begin
session[i-1].request:=true;
session[i-1].CSocket.host:=host;
session[i-1].CSocket.port:=port;
session[i-1].CSocket.active:=true;
session[i-1].lookingup:=true;
session[i-1].lookuptime:=0;
end
else
session[i-1].Csocket.socket.sendtext(session[i-1].request_str);
break;
end;
j:=pos(char(13)+char(10),tmp);
end;
break;
end;
end;
是不是其中分解出来的host有问题?
正常登录时,163邮箱登录时先转到http://reg4.163.com/CheckUser.jsp
后转到http://reg4.163.com/Main.jsp?username=vinvin
代理服务器转到CheckUser.jsp后客户端收到错误页面:
“请求得网址无法获取:无法将输入的主机名称:reg4.163.com转换成ip地址。。。
域名服务器返回以下信息:the domain name does not exist;”
搞不清楚是怎么回事,请大家多多指教!!