hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <ol...@apache.org>
Subject Re: Fw: unable to find line starting with "HTTP" error
Date Fri, 01 Aug 2003 13:28:01 GMT
Hmmm. It seems to work just fine. What is it exactly that you are doing?
Here's the code that works for me:

import org.apache.commons.httpclient.*;
import org.apache.commons.httpclient.methods.*;

public class Test {

 public static void main(String args[]) throws Exception {

  HttpClient httpclient = new HttpClient();
        
  GetMethod httpget = new GetMethod(
"http://www.msnbc.com/news/default.asp?newguid=2594c0a6623f464fb0ff25446bfa6cf3");
  httpget.setRequestHeader("User-Agent", 
   "Mozilla/5.0 (X11; U; Linux i686; it-IT; rv:1.3) Gecko/20030312");
  httpclient.executeMethod(httpget);
  System.out.println(httpget.getStatusLine().toString()); 
 }
}


Here's the resultant wire log:

DEBUG] HttpClient - -Java version: 1.4.2
[DEBUG] HttpClient - -Java vendor: Sun Microsystems Inc.
test/bin:/opt/eclipse/plugins/org.junit_3.8.1/junit.jar:/opt/javalib/jakarta-commons/lib/commons-logging.jar:/home/ok/src/jakarta/httpclient-2.0/bin
[DEBUG] HttpClient - -Operating system name: Linux
[DEBUG] HttpClient - -Operating system architecture: i386
[DEBUG] HttpClient - -Operating system version: 2.4.20-19.9-ok
...
[DEBUG] HttpConnection - -HttpConnection.setSoTimeout(0)
[DEBUG] HttpMethodBase - -Execute loop try 1
[DEBUG] wire - ->> "GET
/news/default.asp?newguid=2594c0a6623f464fb0ff25446bfa6cf3
HTTP/1.1[\r][\n]"
[DEBUG] HttpMethodBase - -Adding Host request header
[DEBUG] wire - ->> "User-Agent: Mozilla/5.0 (X11; U; Linux i686; it-IT;
rv:1.3) Gecko/20030312[\r][\n]"
[DEBUG] wire - ->> "Host: www.msnbc.com[\r][\n]"
[DEBUG] wire - ->> "[\r][\n]"
[DEBUG] wire - -<< "HTTP/1.1 302 Object moved[\r][\n]"
[DEBUG] wire - -<< "Date: Fri, 01 Aug 2003 13:20:12 GMT[\r][\n]"
[DEBUG] wire - -<< "Server: Microsoft-IIS/6.0[\r][\n]"
[DEBUG] wire - -<< "X-Powered-By: ASP.NET[\r][\n]"
[DEBUG] wire - -<< "P3P: CP="BUS CUR CONo FIN IVDo ONL OUR PHY SAMo
TELo"[\r][\n]"
[DEBUG] wire - -<< "Pragma: no-cache[\r][\n]"
[DEBUG] wire - -<< "Set-Cookie: MC1=0; expires=Mon, 31-Dec-2029 23:59:59
GMT; domain=.msnbc.com; path=/[\r][\n]"
[DEBUG] wire - -<< "Location:
http://www.msnbc.com/news/create_p1.asp?cp1=1&cpm=1&cpe=1&URL=www.msnbc.com/news/default.asp&newguid=2594c0a6623f464fb0ff25446bfa6cf3[\r][\n]"
[DEBUG] wire - -<< "Content-Length: 270[\r][\n]"
[DEBUG] wire - -<< "Content-Type: text/html[\r][\n]"
[DEBUG] wire - -<< "Expires: Fri, 01 Aug 2003 01:20:12 GMT[\r][\n]"
[DEBUG] wire - -<< "Cache-control: private[\r][\n]"
[DEBUG] HttpMethodBase - -Cookie accepted: "$Version=0; MC1=0;
$Domain=.msnbc.com; $Path=/"
[DEBUG] HttpMethodBase - -Redirect required
[DEBUG] HttpMethodBase - -Redirect requested to location
'http://www.msnbc.com/news/create_p1.asp?cp1=1&cpm=1&cpe=1&URL=www.msnbc.com/news/default.asp&newguid=2594c0a6623f464fb0ff25446bfa6cf3'
[DEBUG] HttpMethodBase - -Redirecting from
'http://www.msnbc.com:80/news/default.asp' to
'http://www.msnbc.com/news/create_p1.asp?cp1=1&cpm=1&cpe=1&URL=www.msnbc.com/news/default.asp&newguid=2594c0a6623f464fb0ff25446bfa6cf3
[DEBUG] wire - -<< "<head><title>Object moved</title></head>[\n]"
[DEBUG] wire - -<< "<body><h1>Object Moved</h1>This object may be
found
<a
HREF="http://www.msnbc.com/news/create_p1.asp?cp1=1&amp;cpm=1&amp;cpe=1&amp;URL=www.msnbc.com/news/default.asp&amp;newguid=2594c0a6623f464fb0ff25446bfa6cf3">here</a>.</body>[\n]"
[DEBUG] HttpMethodBase - -Resorting to protocol version default close
connection policy
[DEBUG] HttpMethodBase - -Should NOT close connection, using HTTP/1.1.
[DEBUG] HttpMethodBase - -Execute loop try 2
[DEBUG] wire - ->> "GET
/news/create_p1.asp?cp1=1&cpm=1&cpe=1&URL=www.msnbc.com/news/default.asp&newguid=2594c0a6623f464fb0ff25446bfa6cf3
HTTP/1.1[\r][\n]"
[DEBUG] HttpMethodBase - -Request to add Host header ignored: header
already added
[DEBUG] wire - ->> "User-Agent: Mozilla/5.0 (X11; U; Linux i686; it-IT;
rv:1.3) Gecko/20030312[\r][\n]"
[DEBUG] wire - ->> "Host: www.msnbc.com[\r][\n]"
[DEBUG] wire - ->> "Cookie: $Version=0; MC1=0; $Domain=.msnbc.com;
$Path=/[\r][\n]"
[DEBUG] wire - ->> "[\r][\n]"
[DEBUG] wire - -<< "HTTP/1.1 302 Object moved[\r][\n]"
[DEBUG] wire - -<< "Date: Fri, 01 Aug 2003 13:20:12 GMT[\r][\n]"
[DEBUG] wire - -<< "Server: Microsoft-IIS/6.0[\r][\n]"
[DEBUG] wire - -<< "X-Powered-By: ASP.NET[\r][\n]"
[DEBUG] wire - -<< "P3P: CP="BUS CUR CONo FIN IVDo ONL OUR PHY SAMo
TELo"[\r][\n]"
[DEBUG] wire - -<< "Set-Cookie:
MC1=GUID=2594c0a6623f464fb0ff25446bfa6cf3; expires=Mon, 31-Dec-2029
23:59:59 GMT; domain=.msnbc.com; path=/[\r][\n]"
[DEBUG] wire - -<< "Set-Cookie: P1=0; expires=Mon, 31-Dec-2029 23:59:59
GMT; domain=.msnbc.com; path=/[\r][\n]"
[DEBUG] wire - -<< "Location:
http://www.msnbc.com/news/default.asp?cp1=1[\r][\n]"
[DEBUG] wire - -<< "Content-Length: 164[\r][\n]"
[DEBUG] wire - -<< "Content-Type: text/html[\r][\n]"
[DEBUG] wire - -<< "Cache-control: private[\r][\n]"
[DEBUG] HttpMethodBase - -Cookie accepted: "$Version=0;
MC1=GUID=2594c0a6623f464fb0ff25446bfa6cf3; $Domain=.msnbc.com; $Path=/"
[DEBUG] HttpMethodBase - -Cookie accepted: "$Version=0; P1=0;
$Domain=.msnbc.com; $Path=/"
[DEBUG] HttpMethodBase - -Redirect required
[DEBUG] HttpMethodBase - -Redirect requested to location
'http://www.msnbc.com/news/default.asp?cp1=1'
[DEBUG] HttpMethodBase - -Redirecting from
'http://www.msnbc.com:80/news/create_p1.asp' to
'http://www.msnbc.com/news/default.asp?cp1=1
[DEBUG] wire - -<< "<head><title>Object moved</title></head>[\n]"
[DEBUG] wire - -<< "<body><h1>Object Moved</h1>This object may be
found
<a
HREF="http://www.msnbc.com/news/default.asp?cp1=1">here</a>.</body>[\n]"
[DEBUG] HttpMethodBase - -Resorting to protocol version default close
connection policy
[DEBUG] HttpMethodBase - -Should NOT close connection, using HTTP/1.1.
[DEBUG] HttpMethodBase - -Execute loop try 3
[DEBUG] wire - ->> "GET /news/default.asp?cp1=1 HTTP/1.1[\r][\n]"
[DEBUG] HttpMethodBase - -Request to add Host header ignored: header
already added
[DEBUG] wire - ->> "User-Agent: Mozilla/5.0 (X11; U; Linux i686; it-IT;
rv:1.3) Gecko/20030312[\r][\n]"
[DEBUG] wire - ->> "Host: www.msnbc.com[\r][\n]"
[DEBUG] wire - ->> "Cookie: $Version=0;
MC1=GUID=2594c0a6623f464fb0ff25446bfa6cf3; $Domain=.msnbc.com;
$Path=/[\r][\n]"
[DEBUG] wire - ->> "Cookie: $Version=0; P1=0; $Domain=.msnbc.com;
$Path=/[\r][\n]"
[DEBUG] wire - ->> "[\r][\n]"
[DEBUG] wire - -<< "HTTP/1.1 200 OK[\r][\n]"
[DEBUG] wire - -<< "Connection: close[\r][\n]"
[DEBUG] wire - -<< "Date: Fri, 01 Aug 2003 13:20:13 GMT[\r][\n]"
[DEBUG] wire - -<< "Server: Microsoft-IIS/6.0[\r][\n]"
[DEBUG] wire - -<< "X-Powered-By: ASP.NET[\r][\n]"
[DEBUG] wire - -<< "P3P: CP="BUS CUR CONo FIN IVDo ONL OUR PHY SAMo
TELo"[\r][\n]"
[DEBUG] wire - -<< "Pragma: no-cache[\r][\n]"
[DEBUG] wire - -<< "Content-Type: text/html[\r][\n]"
[DEBUG] wire - -<< "Expires: Fri, 01 Aug 2003 01:20:13 GMT[\r][\n]"
[DEBUG] wire - -<< "Cache-control: private[\r][\n]"
[DEBUG] wire - -<< "Accept-Ranges: none[\r][\n]"
[DEBUG] wire - -<< "Transfer-Encoding: chunked[\r][\n]"
[DEBUG] HttpConnection - -HttpConnection.getSoTimeout()

HTTP/1.1 200 OK



Mime
View raw message