String postData = String.Format("privatekey={0}&remoteip={1}&challenge={2}&response={3}",
this.PrivateKey,
this.Page.Request.UserHostAddress,
this.Context.Request.Form[RECAPTCHA_CHALLENGE_FIELD],
this.Context.Request.Form[RECAPTCHA_RESPONSE_FIELD]);
I think we should consider url encoding the challenge & response (I'm not sure if this could be used to make an attack... but it's just a bit worrying)
Ok, I'm running a Windows XP machine and there's no need for HTTP 1.0.I'm running Vista at home, so I'll try that too (maybe it's already improved in 2.0, but I've seen Joseph's code for handling IPv6). But then, it should be the problem for reCPATCHA servers because validation (and matching) between user request and server submission is handled there. IMO, you shouldn't support IPv6 just yet, since no one is using that (other than that LANs and research groups). The only way to do this is that servers should run IPv4 only (this way, users don't need to worry about anything because requests will come through IPv4 address).
Requests to reCAPTCHA servers are encoded in UTF8 (it's the line after string generation). I can implement a pre-request validations (return incorrect if empty, etc.)
I've also implemented a manual IsSecure since I don't know how does secure pages are served. Do you need to code anything or just set config? If code then it's not a big deal, if it's over config, then I'll implement automatic checking based on protocol (just like Joseph's) or based on something else (don't know right now).
Anyone has opinion about proxy support? I mean do you have web servers running behind proxy for external requests? If it does, we might need to eval this scenario.
BTW I'm developing the user control using C# on Windows XP SP2
with .NET 2.0
I had the same 417 Expectation Failed error as Adrian. It seems like
the .NET API adds an 'Expect' HTTP Header when a POST request is used.
So I added some code to suppress this:
request.ServicePoint.Expect100Continue = false;
However, I ran into some other problems when trying to validate the
solution as the server was, according to .NET, closing the connection
prematurely. Looking at the server headers returned by the validation
server it appears that it is using HTTP/1.0, so the closing of the
connection isn't surprising in that context.
So I now use HTTP/1.0 instead of the default, and it don't need to
suppress the Expects header anymore as that is an HTTP/1.1 feature.
I'm using Windows XP, so I'm a bit surprised that Adrian says that
there is no need to use HTTP/1.0, as the server headers clearly
indicate that the server speaks HTTP/1.0
So I now use HTTP/1.0 instead of the default, and it don't need to
suppress the Expects header anymore as that is an HTTP/1.1 feature.
http://msdn2.microsoft.com/en-us/library/system.net.httpwebrequest.servicepoint(VS.80).aspx
On Jun 28, 9:55 am, "Adrian Godong" <adrian.god...@gmail.com> wrote:
> BTW, I can't find any ServicePoint property on my HttpRequest object. Can
> you provide the full namespace? Am I missing something here.
>
> On 6/28/07, Arun <gregoria...@gmail.com> wrote:
>
>
>
>
>
> > I've been experimenting with creating a reCAPTCHA .NET 2.0 user
> > control. This is my first piece of .NET code, so I'm sure I might
> > wrong on a number of counts. But I thought, I might share my
> > experiences.
>
> > BTW I'm developing the user control using C# on Windows XP SP2
> > with .NET 2.0
>
> > I had the same 417 Expectation Failed error as Adrian. It seems like
> > the .NET API adds an 'Expect' HTTP Header when a POST request is used.
> > So I added some code to suppress this:
>
> > request.ServicePoint.Expect100Continue = false;
>
> > However, I ran into some other problems when trying to validate the
> > solution as the server was, according to .NET, closing the connection
> > prematurely. Looking at the server headers returned by the validation
> > server it appears that it is using HTTP/1.0, so the closing of the
> > connection isn't surprising in that context.
>
> > So I now use HTTP/1.0 instead of the default, and it don't need to
> > suppress the Expects header anymore as that is an HTTP/1.1 feature.
>
> > I'm using Windows XP, so I'm a bit surprised that Adrian says that
> > there is no need to use HTTP/1.0, as the server headers clearly
> > indicate that the server speaks HTTP/1.0
>
> --
> Adrian Godong
> adrian.god...@gmail.com
> Microsoft MVPhttps://mvp.support.microsoft.com/profile/Adrian
Just curious why the servers are configured to use HTTP/1.0 instead of
version 1.1, as version 1.0 doesn't support persistent connections.
Given the number of gif images and script files that are downloaded as
part of the reCAPTCHA interface, there should be a noticeable
improvement in network performance if you used version 1.1 instead.
On Jun 28, 10:05 am, "reCAPTCHA Support" <supp...@recaptcha.net>
wrote:
The underlying connection was closed: A connection that was expected
to be kept alive was closed by the server.
The code:
Line 110: HttpWebResponse verificationResponse =
(HttpWebResponse)verificationRequest.GetResponse();
Line 111: StreamReader verificationResponseReader = new
StreamReader(verificationResponse.GetResponseStream(),
Encoding.ASCII);
Is this a server problem or a problem on my end?
HttpWebRequest request = HttpWebRequest.Create(GenerateVerifyUrl()) as
HttpWebRequest;
request.ProtocolVersion = HttpVersion.Version10;
On Jul 11, 7:20 pm, "reCAPTCHA Support" <supp...@recaptcha.net> wrote:
> Did you set the HTTP protocol version to 1.0? This seems to fix things up
> with .net.
>
> On 7/11/07, Timothy Parez <timothypa...@gmail.com> wrote:
>
>
>
>
>
>
>
> > I have my own implementation, very simular to the one described above
> > (as I didn't know about this one)
> > The one thing I get a lot as well is this
>
> > The underlying connection was closed: A connection that was expected
> > to be kept alive was closed by the server.
>
> > The code:
>
> > Line 110: HttpWebResponse verificationResponse =
> > (HttpWebResponse)verificationRequest.GetResponse();
> > Line 111: StreamReader verificationResponseReader = new
> > StreamReader(verificationResponse.GetResponseStream(),
> > Encoding.ASCII);
>
> > Is this a server problem or a problem on my end?
>
> --
> reCAPTCHA: stop spam, read bookshttp://recaptcha.net- Hide quoted text -
>
> - Show quoted text -