求教Internet高手!!!

dcc 2000-07-26 01:39:00

哪位大虾知道关于浏览器与WEB SERVER之间通讯的原理或有关这方面的资料?

请联系我:hzdcc@21cn.com
高分酬谢!!!


...全文
114 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
ZHX 2000-07-27
  • 打赏
  • 举报
回复
看RFC2068, 以下是一个获得Web Server信息的例子:

void QueryInfo(String strHost, String strHostPort, String strProxy, String strPort) throws Exception
{
byte buf[] = new byte[BUF_SIZE];
Socket s;
InputStream ins;
// BufferedInputStream ins;
OutputStream outs;
int c;
int n;
String strCmd;
int HostPort, ProxyPort;
boolean bProxy = true;

try {
HostPort = Integer.parseInt(strHostPort);
} catch(NumberFormatException nfe) {
HostPort = 80;
textHostPort.setText(Integer.toString(HostPort));
}

if (strProxy.length() == 0)
bProxy = false;


if (bProxy)
{
try {
ProxyPort = Integer.parseInt(textProxyPort.getText());
} catch(NumberFormatException nfe) {
ProxyPort = 80;
textProxyPort.setText(Integer.toString(ProxyPort));
}

s = new Socket(strProxy, ProxyPort);
}
else
{
s = new Socket(strHost, HostPort);
}

ins = s.getInputStream();
outs = s.getOutputStream();

strCmd = new String("HEAD http://"+strHost+":"+HostPort+"/ HTTP/1.0\r\n");
strCmd += "Host: "+strHost+"\r\n";
strCmd += "Accept: */*\r\n";
strCmd += "User-Agent: Prober 1.0\r\n";

if (bProxy) {
strCmd += "Proxy-Connection: Keep-Alive\r\n";
}
else
{
strCmd += "Connection: close\r\n";
}

//strCmd = new String("CONNECT "+strHost+":"+HostPort+" HTTP/1.1\r\n");
strCmd += "\r\n";
outs.write(toBytes(strCmd));

textResult.append("Command Sent: \n"+strCmd);
textResult.append("\nServer Response: \n");

n = 0;
while ( (c = ins.read()) != -1)
{
buf[n] = (byte)c;
n++;
if ( n == BUF_SIZE) {
break;
}
}
ins.close();
outs.close();
s.close();

textResult.append(new String(buf));
}
茂奇软件 2000-07-27
  • 打赏
  • 举报
回复
search the RFC.
LaoZheng 2000-07-27
  • 打赏
  • 举报
回复
自己写浏览器?
蝈蝈俊 2000-07-26
  • 打赏
  • 举报
回复
就是http的资料????

4,356

社区成员

发帖
与我相关
我的任务
社区描述
通信技术相关讨论
社区管理员
  • 网络通信
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧