You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by RZG <re...@gmail.com> on 2006/02/26 04:39:36 UTC
cannot load rss xml with httpclient 3.0 .
Hi! everybody,
when i attempted load a rss url using PostMethod in httpclient 3.0,an 403
status returned.
but i can access this rss url through the ie or other browsers.
would there be any parameters must be setted?
*my code as follow:*
MultiThreadedHttpConnectionManager connectionManager = new
MultiThreadedHttpConnectionManager();
HttpClient httpClient = new HttpClient(connectionManager);
GetMethod postMethod = new GetMethod(
"
http://groups.google.com/group/PowereEngin/feed/rss_v2_0_msgs.xml?num=50");
int httpStatus = httpClient.executeMethod(postMethod);
char abyte1[] = new char[10240];
System.out.println(httpStatus);
try {
Reader reader = new InputStreamReader(postMethod
.getResponseBodyAsStream());
int readlen = reader.read(abyte1);
char b[] = new char[readlen];
System.arraycopy(abyte1, 0, b, 0, readlen);
System.out.println(b);
} catch (Exception ex) {
ex.printStackTrace();
} finally {
postMethod.releaseConnection();
}
*returned msg from the google group's host:*
<html><head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>403 Forbidden</title>
<style><!--
body {font-family: arial,sans-serif}
div.nav {margin-top: 1ex}
div.nav A {font-size: 10pt; font-family: arial,sans-serif}
span.nav {font-size: 10pt; font-family: arial,sans-serif; font-weight: bold}
div.nav A,span.big {font-size: 12pt; color: #0000cc}
div.nav A {font-size: 10pt; color: black}
A.l:link {color: #6f6f6f}
A.u:link {color: green}
//--></style>
</head>
<body text=#000000 bgcolor=#ffffff>
<table border=0 cellpadding=2 cellspacing=0 width=100%><tr><td rowspan=3
width=1% nowrap>
<b><font face=times color=#0039b6 size=10>G</font><font face=times
color=#c41200 size=10>o</font><font face=times color=#f3c518
size=10>o</font><font face=times color=#0039b6 size=10>g</font><font
face=times color=#30a72f size=10>l</font><font face=times color=#c41200
size=10>e</font> </b>
<td> </td></tr>
<tr><td bgcolor=#3366cc><font face=arial,sans-serif
color=#ffffff><b>Error</b></td></tr>
<tr><td> </td></tr></table>
<blockquote>
*<H1>Forbidden</H1>
Your client does not have permission to get URL
<code>/group/PowereEngin/feed/rss_v2_0_msgs.xml?num=50</code> from this
server.*
*<*p>
</blockquote>
<table width=100% cellpadding=0 cellspacing=0><tr><td bgcolor=#3366cc><img
alt="" width=1 height=4></td></tr></table>
</body></html>
*tks for veryone's help!*
--
RenZenggang
Renzenggang@gmail.com
Renzenggang@csii.com
MSN:rzg117@hotmail.com
Re: cannot load rss xml with httpclient 3.0 .
Posted by Ortwin Glück <od...@odi.ch>.
Why are you using a POST method? Have you tried using a GET method?
RZG wrote:
> Hi! everybody,
>
> when i attempted load a rss url using PostMethod in httpclient 3.0,an 403
> status returned.
> but i can access this rss url through the ie or other browsers.
> would there be any parameters must be setted?
>
> *my code as follow:*
>
> MultiThreadedHttpConnectionManager connectionManager = new
> MultiThreadedHttpConnectionManager();
> HttpClient httpClient = new HttpClient(connectionManager);
> GetMethod postMethod = new GetMethod(
> "
> http://groups.google.com/group/PowereEngin/feed/rss_v2_0_msgs.xml?num=50");
> int httpStatus = httpClient.executeMethod (postMethod);
> char abyte1[] = new char[10240];
> System.out.println(httpStatus);
> try {
> Reader reader = new InputStreamReader(postMethod
> .getResponseBodyAsStream());
> int readlen = reader.read (abyte1);
> char b[] = new char[readlen];
> System.arraycopy(abyte1, 0, b, 0, readlen);
> System.out.println(b);
> } catch (Exception ex) {
> ex.printStackTrace();
> } finally {
> postMethod.releaseConnection ();
> }
>
--
[web] http://www.odi.ch/
[blog] http://www.odi.ch/weblog/
[pgp] key 0x81CF3416
finger print F2B1 B21F F056 D53E 5D79 A5AF 02BE 70F5 81CF 3416
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-dev-help@jakarta.apache.org
cannot load rss xml with httpclient 3.0 .
Posted by RZG <re...@gmail.com>.
Hi! everybody,
when i attempted load a rss url using PostMethod in httpclient 3.0,an 403
status returned.
but i can access this rss url through the ie or other browsers.
would there be any parameters must be setted?
*my code as follow:*
MultiThreadedHttpConnectionManager connectionManager = new
MultiThreadedHttpConnectionManager();
HttpClient httpClient = new HttpClient(connectionManager);
GetMethod postMethod = new GetMethod(
"
http://groups.google.com/group/PowereEngin/feed/rss_v2_0_msgs.xml?num=50");
int httpStatus = httpClient.executeMethod (postMethod);
char abyte1[] = new char[10240];
System.out.println(httpStatus);
try {
Reader reader = new InputStreamReader(postMethod
.getResponseBodyAsStream());
int readlen = reader.read (abyte1);
char b[] = new char[readlen];
System.arraycopy(abyte1, 0, b, 0, readlen);
System.out.println(b);
} catch (Exception ex) {
ex.printStackTrace();
} finally {
postMethod.releaseConnection ();
}
*returned msg from the google group's host:*
<html><head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>403 Forbidden</title>
<style><!--
body {font-family: arial,sans-serif}
div.nav {margin-top: 1ex}
div.nav A {font-size: 10pt; font-family: arial,sans-serif}
span.nav {font-size: 10pt; font-family: arial,sans-serif; font-weight: bold}
div.nav A,span.big {font-size: 12pt; color: #0000cc}
div.nav A {font-size: 10pt; color: black}
A.l:link {color: #6f6f6f}
A.u:link {color: green}
//--></style>
</head>
<body text=#000000 bgcolor=#ffffff>
<table border=0 cellpadding=2 cellspacing=0 width=100%><tr><td rowspan=3
width=1% nowrap>
<b><font face=times color=#0039b6 size=10>G</font><font face=times
color=#c41200 size=10>o</font><font face=times color=#f3c518
size=10>o</font><font face=times color=#0039b6 size=10>g</font><font
face=times color=#30a72f size=10>l</font><font face=times color=#c41200
size=10>e</font> </b>
<td> </td></tr>
<tr><td bgcolor=#3366cc><font face=arial,sans-serif
color=#ffffff><b>Error</b></td></tr>
<tr><td> </td></tr></table>
<blockquote>
*<H1>Forbidden</H1>
Your client does not have permission to get URL
<code>/group/PowereEngin/feed/rss_v2_0_msgs.xml?num=50</code> from this
server. *
*<*p>
</blockquote>
<table width=100% cellpadding=0 cellspacing=0><tr><td bgcolor=#3366cc><img
alt="" width=1 height=4></td></tr></table>
</body></html>
*tks for veryone's help!*
--
RenZenggang
Renzenggang@gmail.com
MSN:rzg117@hotmail.com <rz...@hotmail.com>
Re: cannot load rss xml with httpclient 3.0 .
Posted by Roland Weber <ht...@dubioso.net>.
Hi RZG,
> when i attempted load a rss url using PostMethod in httpclient 3.0,an 403
> status returned.
> but i can access this rss url through the ie or other browsers.
> would there be any parameters must be setted?
Most likely.
> GetMethod postMethod = new GetMethod(
The type of a method does not depend on the variable name. If you create
an object of type GetMethod, it will be a GET method, no matter how many
"post" you put into the variable name.
That is probably not the only error in your code.
I suggest you go through the checklist...
http://mail-archives.apache.org/mod_mbox/jakarta-httpclient-user/200602.mbox/%3C43ECC443.8020004@dubioso.net%3E
Don't take the "identical" in step 7 literally.
The followup mails will tell you what I mean.
cheers,
Roland
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org