Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / .NET SDK / April 2006

Tip: Looking for answers? Try searching our database.

Redirected request in HttpWebRequest does not maintain specified method!!

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jon Davis - 27 Mar 2004 06:37 GMT
This appears to be a critical bug in the .NET Framework. Surely I am wrong
though! PLEASE HELP if anyone has any idea?

Thanks,
Jon

________________________________

From: Jon Davis [mailto:jon@accentra.net]
Sent: Friday, March 26, 2004 9:31 PM
To: bloggerDev@yahoogroups.com
Subject: RE: [bloggerDev] Blogger API still not working for me :`(

Seems the AutoRedirect feature in the HttpWebRequest object in .NET
Framework does not maintain the specified method. It's changing from a POST
to a GET.

Sniffed conversation is as follows.

----------------------------
REQUEST (api.blogger.com:80)
----------------------------
POST /api HTTP/1.1
Content-Type: text/xml
User-Agent: Accentra.XmlRpc 1.4
Content-Length: 495
Expect: 100-continue
Connection: Keep-Alive
Host: api.blogger.com

--------
RESPONSE
--------
HTTP/1.0 302 Found
Date: Sat, 27 Mar 2004 05:25:31 GMT
Server: Apache
Location: http://www.blogger.com/api
Connection: close
Content-Type: text/html; charset=iso-8859-1

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML><HEAD>
<TITLE>302 Found</TITLE>
</HEAD><BODY>
<H1>Found</H1>
The document has moved <A HREF="http://www.blogger.com/api">here</A>.<P>
</BODY></HTML>

----------------------------
REQUEST (www.blogger.com:80)
----------------------------

GET /api HTTP/1.1
Content-Type: text/xml
User-Agent: Accentra.XmlRpc 1.4
Connection: Keep-Alive
Host: www.blogger.com

--------
RESPONSE
--------

HTTP/1.0 302
Date: Sat, 27 Mar 2004 05:25:31 GMT
Server: Apache
Vary: Accept-Encoding
Location: http://www.blogger.com/developers/api/
Content-Length: 0
Connection: close
Content-Type: text/html

-------
REQUEST
-------

GET /developers/api/ HTTP/1.1
Content-Type: text/xml
User-Agent: Accentra.XmlRpc 1.4
Connection: Keep-Alive
Host: www.blogger.com

--------
RESPONSE
--------

HTTP/1.0 200
Date: Sat, 27 Mar 2004 05:25:33 GMT
Server: Apache
Vary: Accept-Encoding
Set-Cookie: JSESSIONID=B3B178D78922757B3761FDC6EB1C454F; Path=/
Set-Cookie: ServerID=1290; Path=/
Set-Cookie: PyraID2=; Expires=Thu, 01-Jan-1970 00:00:10 GMT
Content-Length: 319
Connection: close
Content-Type: text/html;charset=ISO-8859-1

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
     <title>Blogger API</title>
</head>

<body style="font-family:sans-serif;font-size:12px;">
<h1>Blogger API</h1>
<br><br>
<div >
&nbsp;&nbsp;&nbsp;<a href="1_docs">Blogger API 1.0 Documentation</a>
</div>

</body>
</html>

-----Original Message-----
From: Steve Jenson [mailto:stevej@pobox.com]
Sent: Friday, March 26, 2004 10:40 AM
To: bloggerDev@yahoogroups.com
Subject: Re: [bloggerDev] Blogger API still not working for me :`(

Since XML-RPC only uses POST, I redirect to that address when somebody sends
a GET (i.e. they request http://www.blogger.com/api in their browser). It
shouldn't be redirecting otherwise. I see in your code that you've specified
POST as your HTTP method so I can't explain why you're seeing this
particular redirects I did just use the blogger api from Ecto, though, to
post to a test blog of mine.

I would use tcpmon[1] to watch the http traffic to see what's up.

Best,
Steve

[1]: http://www.intertwingly.net/blog/1575.html

On Mar 26, 2004, at 3:15 AM, Jon Davis wrote:

> Verified. It is redirecting to http://www.blogger.com/developers/api/.
> Why?
>
> From: Jon Davis [mailto:jon@accentra.net]
>  Sent: Friday, March 26, 2004 3:05 AM
> To: bloggerDev@yahoogroups.com
> Subject: RE: [bloggerDev] Blogger API still not working for me :`(
>
> The code is written in C#.
>
> Why is Blogger redirecting to
> http://www.blogger.com/developers/api/ or
<http://www.blogger.com/developers/api/ or>  spitting back equivalent
> HTML thereof, rather than taking the POST?
>
> By the way, this was working before a few months ago, before
> redirections occurred.
>
> Jon
>
> From: Jon Davis [mailto:jon@accentra.net]
>  Sent: Friday, March 26, 2004 12:52 AM
> To: bloggerDev@yahoogroups.com
> Subject: [bloggerDev] Blogger API still not working for me :`(
>
> Eh, I have finally gotten around to focusing again on Blogger API
> support in PowerBlog v2. This is the last round of bug fixes I'm
> focusing on in this product before gold release, everything else is
> pretty much done.
>
> There are two serious problems I'm having with the Blogger server. I'd
> thought it was a redirection problem, with .NET framework not
> redirecting its HttpWebRequest properly, but that's apparently not it.
> Actually, there are two problems.
>
> The first problem is that the server is terminating the connection
> before I've finished sending the request (and yes, as far as I know,
> the ContentLength is correct). The second problem is that the crap it
> spits back is just the HTML hyperlink to the documentation.
> It's not letting me submit the XML-RPC invocation at all!
>
> If you have an HTML-capable newsreader, my comments to this group is
> in  bold
>
>             // calling http://api.blogger.com/api, "blogger.getPost",
> ...
>
>             public object Call(Uri uri, string Method, params object[]
> Params) {
>
>                   // build and send request
>
>                   HttpWebRequest req =
>
>                         (HttpWebRequest)WebRequest.Create(uri);
>
>                   req.Proxy = ProxySettings;
>
>                   req.CookieContainer = Cookies;
>
>                   for (int i=0;i<Certificates.Count;i++) {
>
>                         req.ClientCertificates.Add(Certificates[i]);
>
>                   }
>
>                   req.ContentType = "text/xml";
>
>                   req.Method = "POST";
>
>                   req.UserAgent = UserAgent;
>
>                   for (int i=0;i<Headers.Count;i++) {
>
>                         req.Headers.Add(Headers[i]);
>
>                   }
>
>                   string reqBody = BuildRequest(Method, Params,
> Encoding);
>
>                   // so now reqBody is as follows:
>
>                   // <?xml version="1.0"?>
>                   // <methodCall>
>                   //  <methodName>blogger.newPost</methodName>
>                   //  <params>
>                   //
>   <param><value><string>B9C296C4DC1F09ED61129B1FDBFFE589482E5DAA</
> string></value></param>
>                   //
>   <param><value><string>3603466</string></value></param>
>                   //
>   <param><value><string>[name]</string></value></param>
>                   //
>   <param><value><string>[pw]</string></value></param>
>                   //   <param><value><string>hello, it
> works</string></value></param>
>                   //
>   <param><value><boolean>1</boolean></value></param>
>                   //  </params></methodCall>
>
>                                    System.Text.UTF8Encoding encoding =
> new UTF8Encoding();
>
>                   byte[] byteReqBody=encoding.GetBytes(reqBody);
>
>                   req.ContentLength = byteReqBody.Length;
>
>                   Stream st;
>
>                   WebResponse wr;
>
>                   StreamReader sr;
>
>                   try {
>
>                         st = req.GetRequestStream();
>
>                   } catch (Exception ex) {
>
>                         throw new XmlRpcConnectException(ex.Message,
> ex);
>
>                   }
>
>                   try {
>
>                         st.Write(byteReqBody, 0, byteReqBody.Length);
>
>                         st.Flush();
>
>                   } catch (System.Net.WebException ex) {
>
>                         // dies here, tells me it closed unexpectedly
>
>                         // ... so here I'm just going to ignore it and
> move on
>
>                         if (ex.Message.IndexOf("closed unexpectedly")
> == -1) {
>
>                               throw ex;
>
>                         }
>
>                   }
>
>                   // receive and parse response
>
>                   wr = req.GetResponse();
>
>                   sr = new StreamReader(wr.GetResponseStream());
>
>                   string resp = sr.ReadToEnd();
>
>                   // here I find that the response is just some HTML
>
>                   try { sr.Close();} catch {}
>
>                   try {wr.Close();} catch {}
>
>                   try {st.Close();} catch {}
>
>                   return
> XmlRpcTools.ConvertElement(ParseResponse(resp), false);
>
>             }
Jon Davis - 27 Mar 2004 06:42 GMT
I think I know what it's doing. It's redirecting AFTER posting, rather than
following the redirect in order to post.

Who's to blame here, the server for not accepting a POST until the redirect,
or the client for not following the redirect before POSTing?

Jon

> This appears to be a critical bug in the .NET Framework. Surely I am wrong
> though! PLEASE HELP if anyone has any idea?
[quoted text clipped - 299 lines]
> >
> >             }
Jon Davis - 27 Mar 2004 07:05 GMT
From: Jon Davis [mailto:jon@accentra.net]
Sent: Friday, March 26, 2004 10:04 PM
To: bloggerDev@yahoogroups.com
Subject: [bloggerDev] There should only be one POST per HTTP query

Sorry to spam this mailing list, Group, but I just want to add one more
comment.

Steve, when a server redirects a POST, the expectation for the client is
that the redirection is the result of the POST. You wouldn't expect a web
browser to re-POST the same HTML form after following the redirect that came
back from the form's POST, would you? Likewise, why would you expect an
XML-RPC client to expect to re-post the content after the redirect, when it
would make as much sense for it to expect that the response in the
redirected URL is just that--a response, to the previously posted POST?

An HTTP server response is just that: a RESPONSE. The client expects the
response to be a valid response. If it is a redirection, the client GETs
from the new URL in order to obtain the response. Redirections before
processing should only occur when GETting. Otherwise, the redirection should
pre-handle the POST before spitting back the new URL.

Otherwise, Steve, you need to extend the Blogger API to offer a GET
mechanism to query the server for the valid URL before POSTing the content.
The redirection should come from a GET; otherwise, if it is from a POST, the
content should be processed before you return a redirect, or else the client
will have NO WAY of knowing whether the POST was handled (except in the
unexpected termination issue, which is completely unreliable because the
Request content might be fully submitted before the server terminates).

Let me put it in other words: there should only be one POST in any single
HTTP query. Period.

Jon

----------------------------------------------------------------------------
----
From: Jon Davis [mailto:jon@accentra.net]
Sent: Friday, March 26, 2004 9:48 PM
To: bloggerDev@yahoogroups.com
Subject: RE: [bloggerDev] Blogger API still not working for me :`(

Clearly, there is a tragic disconnect of HTTP protocol expectations here.
The server wants the client to redirect before POSTing, and the client wants
to POST before redirecting.

So, who's to blame here, the server for not accepting a POST until the
redirect, or the client for not following the redirect before POSTing?

I think Microsoft makes more sense to follow the redirect after POSTing,
because their ASP.NET paradigm is a redirection-driven process that requires
POST-before-redirect in order to function correctly.

I can work around this, I think, by catching the "terminated unexpectedly"
exception and retrying the redirected URL with a POST. But I REALLY don't
like this, and I feel that this whole redirection nonsense is a design flaw
on Blogger.com's end.

Jon

> I think I know what it's doing. It's redirecting AFTER posting, rather than
> following the redirect in order to post.
[quoted text clipped - 310 lines]
> > >
> > >             }
Jon Davis - 27 Mar 2004 07:15 GMT
From: Jon Davis [mailto:jon@accentra.net]
Sent: Friday, March 26, 2004 10:14 PM
To: 'bloggerDev@yahoogroups.com'
Subject: RE: [bloggerDev] There should only be one POST per HTTP query

And by the way, please don't tell me that XML-RPC doesn't use GET so
redirects should POST again. As far as I know, redirections are not part of
the XML-RPC specification.

Jon

> From: Jon Davis [mailto:jon@accentra.net]
> Sent: Friday, March 26, 2004 10:04 PM
[quoted text clipped - 375 lines]
> > > >
> > > >             }
Jon Davis - 27 Mar 2004 09:34 GMT
Perhaps there is indeed a bug in the .NET Framework.

This is what Steve Jenson says:

From: Steve Jenson [mailto:stevej@pobox.com]
Sent: Friday, March 26, 2004 10:53 PM
To: bloggerDev@yahoogroups.com
Subject: Re: [bloggerDev] Blogger API still not working for me :`(

> Clearly, there is a tragic disconnect of HTTP protocol expectations
> here. The server wants the client to redirect before POSTing, and the
> client wants to POST before redirecting.

The specification wants you to POST both times. (with a caveat stated
below)

> So, who's to blame here, the server for not accepting a POST until the
> redirect, or the client for not following the redirect before POSTing?
[quoted text clipped - 3 lines]
> process that requires POST-before-redirect in order to function
> correctly.

It might be doing this because section 10.3.3 of HTTP 1.1 says that
methods other than GET or HEAD are required to request of the user
whether or not they should continue on the redirect.

Automatically following a redirect with a different method is obviously
wrong and doesn't follow this recommendation regardless. I believe that
Microsoft's client has a bug in it.

-steve

> From: Jon Davis [mailto:jon@accentra.net]
> Sent: Friday, March 26, 2004 10:14 PM
[quoted text clipped - 296 lines]
> > > > >
> > > > >                   for (int i=0;i<Certificates.Count;i++) {

req.ClientCertificates.Add(Certificates[i]);

> > > > >                   }
> > > > >
[quoted text clipped - 105 lines]
> > > > >
> > > > >             }
Nico Vrouwe - 27 Mar 2004 07:06 GMT
Hi,

The server is not to blame here, because it's up to the client wether to
follow a redirect URL or not. The server really couldn't care less ;)

HTH,
Nico Vrouwe

> I think I know what it's doing. It's redirecting AFTER posting, rather than
> following the redirect in order to post.
[quoted text clipped - 310 lines]
> > >
> > >             }
Jerry Pisk - 27 Mar 2004 19:39 GMT
But to have the client repost the same data you need to use 307, not 302.
But no client will automatically repost data to a redirected url, it's a
huge security risk, so forget about doing it.

Jerry

> Hi,
>
[quoted text clipped - 323 lines]
> > > >
> > > >             }
Feroze [MSFT] - 05 Apr 2004 04:08 GMT
Hi!

I am assuming that you want the client to redirect using POST, instead of
GET.

In that case, the server should send back a redirect code of 307. Since the
server is sending back a 301 redirect, the client changes the request method
to a GET.

This is by design, per the HTTP RFC ( http://www.ietf.org/rfc/rfc2616.txt )

Thanks.

Signature

feroze
http://weblogs.asp.net/feroze_daud
============

Remove "user" from the email address to reply to the author.

This posting is provided "AS IS" with no warranties, and confers no rights

Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

> This appears to be a critical bug in the .NET Framework. Surely I am wrong
> though! PLEASE HELP if anyone has any idea?
[quoted text clipped - 299 lines]
> >
> >             }
Free Music Downloads - 06 Apr 2006 05:51 GMT
 
Free Music Downloads

http://www.manifestingpower.com/seo/music.html        

Free Mp3 Music Download  

All Free Music Downloads Download Games VIdeos are very authentic looking. Free Music Downloads is one of todays most popular styles! Please take a look at our Free Music Downloads Download Games VIdeos and you will see that our Free Mp3 Music Downloads are the highest quality Free Mp3 Music Download Games VIdeos availiable! We are selling Free Mp3 Music Downloads daily! Get your Free Mp3 Music Download while supplies last. All of our Free Mp3 Music Download are made of the same material as authentic Free Mp3 Music Download. Our Free Mp3 Music Download is truly amazing. We carry the hardest to get Games VIdeos and the most popular styles. Our Free Mp3 Music Download are 100% exact.. All of our Games VIdeos knockoffs and Free Mp3 Music Download knockoffs have all correct markings. We are proud to offer exclusive grade Games VIdeos Free  Music Download Downloads. We offer the most exact fake Free  Music Download. Our exclusive grade Games VIdeos s can not be found elsewhere. These are the most exact Free Mp3 Music Download knockoffs you will ever see. We don't just claim to offer the best fake Free Mp3 Music Download, we guarantee we offer the best and most exact fake Free Mp3 Music Download. We have many styles to offer Suhali, dalmation, and many other fake Free  Music Downloads Games VIdeos Games VIdeos . We have the highest quality Downloads on the web! Affordable prices, great service, and a Satisfaction Guarantee make free-mp3-music-download.com the right choice for all of your Games VIdeos Download needs! Buy one today for a gift, for a friend, or for YOURSELF! You deserve Games VIdeos quality at an affordable price, thats why we started ExactGames VIdeos .com! All of the Free Mp3 Music Download knockoffs in our site come with a satisfaction guarantee. Please take your time and look at all the Games VIdeos we have to offer. We have something for everyone. We are sure you will love the perfect quality of our Free Music Downloads. Most of the Download fake Games VIdeos Games VIdeos we offer even have a serial number and every single detail you can think of.

Free  Music Downloads
Free Mp3 Music
Free  Music Download
Free Mp3 Music Download

Free Mp3 Music Download Games VIdeos

Free Mp3 Music Download and Download Free Mp3 Music Games  

     
http://www.manifestingpower.com/seo/music.html        

Free Music Downloads

Posted via DevelopmentNow.com Groups
http://www.developmentnow.com

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.