应该是在WORD = IN.READ(TEMP)处阻塞!!
采用单字节也是这样!

解决方案 »

  1.   

    有5种方式可以确定html内容的长度:1. 一直到socket连接断开。2. 由Content-Length头指定html内容长度3. 如果Transfer-Encoding为chunked,那么html内容是进行chunk编码。4. Content-Type是multipart/byteranges5. 有些HTTP响应不能有内容体。
      

  2.   

    to  echou(岸边蚕豆):
    第一种方法不可行!不可能等到socket断开,才处理内容
    第二种方法,我早时试过了,效果都不错,不幸的是,碰到了一些页面没有返回Content-Length属性,现在不得不找其他方法
    第五种方法,不能确定其他有返回内容的页面
    4,5不是很熟悉他的运作情况,但根据读取回来http协议信息
    可能没有Transfer-Encoding属性信息
      

  3.   

    这是我后来的得到的结果,大家来帮帮我。通过Socket向Web server 发送request,1.使用http/1.0格式如下
      String request2 = ""
             + "GET / HTTP/1.0\r\n"
             + "Host: localhost\r\n\r\n";页面返回正常2.使用http/1.1格式如下
      String request1 = ""
             + "GET / HTTP/1.1\r\n"
             + "Accept: */*\r\n"
             + "Accept-Language: zh-cn\r\n"
             + "Accept-Encoding: gzip, deflate\r\n"
             + "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)\r\n"
             + "Host: localhost\r\n"
             + "Connection: Keep-Alive\r\n\r\n";发送返回的页面会出现延迟现象,但页面正常估计是读取最后一个结束标志出现了问题读取程序如下:
      ByteArrayOutputStream bos = new ByteArrayOutputStream(1024*10);
      byte[] temp = new byte[1024];
      int len;
      while ((len=in.read(temp))!=-1){
          byte[] temp1 = new byte[len];
          System.arraycopy(temp,0,temp1,0,len);
          System.out.print(new String(temp1));
          bos.write(temp,0,len);
      }
      System.out.println("end read");
      bos.flush();
      temp = bos.toByteArray();
      

  4.   

    又有新问题了,
    HTTP/1.1 100 Continue 
    Date: Fri, 18 Apr 2003 11:43:44 GMT 
    Server: Microsoft-IIS/5.0code为100的协议没有chunked和length字段!!返回的内容无长度!!结束符.