From: kay <ka...@gm...> - 2010-07-11 07:42:10
|
Hi everybody, I am a student who has participated in the Fedora Summer Coding and takes the project of updating and implementing the chat room function in the Libyahoo2. The source code I have been using is http://github.com/kay21s/Libyahoo2 Currently I have met a problem when implementing the captcha when joining a chat room, I used a new connection type to receive the response from the server. After I input the wrong captcha in the first time, the server will response only one message with a new URL of the image. However, since then, the same response will be received twice, and the two same responses are at different memory addresses. The process is main()->yahoo_callback()->yahoo_read_ready()->yahoo_process_captcha_connection() I cannot find why it will process the same response twice, have any good suggestions? Thanks very much! -- --Kay |
From: Siddhesh P. <sid...@gm...> - 2010-07-11 18:28:10
|
On Sun, Jul 11, 2010 at 1:12 PM, kay <ka...@gm...> wrote: > Hi everybody, > I am a student who has participated in the Fedora Summer Coding and takes > the project of updating and implementing the chat room function in the > Libyahoo2. > The source code I have been using is http://github.com/kay21s/Libyahoo2 > Currently I have met a problem when implementing the captcha when joining a > chat room, I used a new connection type to receive the response from the > server. > After I input the wrong captcha in the first time, the server will response > only one message with a new URL of the image. > However, since then, the same response will be received twice, and the two > same responses are at different memory addresses. > The process is > main()->yahoo_callback()->yahoo_read_ready()->yahoo_process_captcha_connection() > I cannot find why it will process the same response twice, have any good > suggestions? You need to close and remove the older connection; AFAIK HTTP/1.1 connections don't terminate by themselves, unlike HTTP/1.0. Also, unrelated to your question, instead of searching for the "The document has moved" string, you ought to be checking the HTTP status code in the first line of the http response. -- Siddhesh Poyarekar http://siddhesh.in |
From: kay <ka...@gm...> - 2010-07-12 10:41:30
|
Thanks for your suggestion, it works now =) I cannot check the HTTP status, whether the captcha is correct or wrong, the HTTP status is always 301 I find the "The document has moved" is to goto the content of the HTTP message in order to find if what is sent is right or the URL of a new image. 2010/7/12 Siddhesh Poyarekar <sid...@gm...> > On Sun, Jul 11, 2010 at 1:12 PM, kay <ka...@gm...> wrote: > > Hi everybody, > > I am a student who has participated in the Fedora Summer Coding and takes > > the project of updating and implementing the chat room function in the > > Libyahoo2. > > The source code I have been using is http://github.com/kay21s/Libyahoo2 > > Currently I have met a problem when implementing the captcha when joining > a > > chat room, I used a new connection type to receive the response from the > > server. > > After I input the wrong captcha in the first time, the server will > response > > only one message with a new URL of the image. > > However, since then, the same response will be received twice, and the > two > > same responses are at different memory addresses. > > The process is > > > main()->yahoo_callback()->yahoo_read_ready()->yahoo_process_captcha_connection() > > I cannot find why it will process the same response twice, have any good > > suggestions? > > You need to close and remove the older connection; AFAIK HTTP/1.1 > connections don't terminate by themselves, unlike HTTP/1.0. > > Also, unrelated to your question, instead of searching for the "The > document has moved" string, you ought to be checking the HTTP status > code in the first line of the http response. > > > -- > Siddhesh Poyarekar > http://siddhesh.in > -- --Kay |
From: Siddhesh P. <sid...@gm...> - 2010-07-12 10:30:52
|
(Do a reply-all so that the response goes to the mailing list as well) 2010/7/12 kay <ka...@gm...>: > Thanks for your suggestion, it works now =) > I cannot check the HTTP status, whether the captcha is correct or wrong, the > HTTP status is always 301 > I find the "The document has moved" is to goto the content of the HTTP > message in order to find if what is sent is right or the URL of a new image. If it is just to find the captcha url then you can simply get away by looking for "a href" and then parsing the link within that tag. But if you want to be sure that you received the expected response from the server (HTTP 301 instead of, say, 404 or 500) then you ought to be looking for the response code and not the string. -- Siddhesh Poyarekar http://siddhesh.in |
From: Siddhesh P. <sid...@gm...> - 2010-07-12 10:32:14
|
2010/7/12 Siddhesh Poyarekar <sid...@gm...>: > (Do a reply-all so that the response goes to the mailing list as well) > > 2010/7/12 kay <ka...@gm...>: >> Thanks for your suggestion, it works now =) >> I cannot check the HTTP status, whether the captcha is correct or wrong, the >> HTTP status is always 301 >> I find the "The document has moved" is to goto the content of the HTTP >> message in order to find if what is sent is right or the URL of a new image. > > If it is just to find the captcha url then you can simply get away by > looking for "a href" and then parsing the link within that tag. But if > you want to be sure that you received the expected response from the > server (HTTP 301 instead of, say, 404 or 500) then you ought to be > looking for the response code and not the string. > Ohh, and it would be a pretty neat idea to have something of an http response struct passed back to the calling function, which will give details about the http headers. Right now we simply hack through the headers and choose what we want. -- Siddhesh Poyarekar http://siddhesh.in |
From: kay <ka...@gm...> - 2010-07-12 10:44:50
|
Yes, but it is hard to have a general HTTP structure, since there are so many fields in HTTP protocol I think it is a good idea to divide the HTTP header and the HTTP content 在 2010年7月12日 下午6:32,Siddhesh Poyarekar <sid...@gm...>写道: > 2010/7/12 Siddhesh Poyarekar <sid...@gm...>: > > (Do a reply-all so that the response goes to the mailing list as well) > > > > 2010/7/12 kay <ka...@gm...>: > >> Thanks for your suggestion, it works now =) > >> I cannot check the HTTP status, whether the captcha is correct or wrong, > the > >> HTTP status is always 301 > >> I find the "The document has moved" is to goto the content of the HTTP > >> message in order to find if what is sent is right or the URL of a new > image. > > > > If it is just to find the captcha url then you can simply get away by > > looking for "a href" and then parsing the link within that tag. But if > > you want to be sure that you received the expected response from the > > server (HTTP 301 instead of, say, 404 or 500) then you ought to be > > looking for the response code and not the string. > > > > Ohh, and it would be a pretty neat idea to have something of an http > response struct passed back to the calling function, which will give > details about the http headers. Right now we simply hack through the > headers and choose what we want. > > > -- > Siddhesh Poyarekar > http://siddhesh.in > -- --Kay |
From: Siddhesh P. <sid...@gm...> - 2010-07-12 11:20:00
|
2010/7/12 kay <ka...@gm...>: > Yes, but it is hard to have a general HTTP structure, since there are so > many fields in HTTP protocol > I think it is a good idea to divide the HTTP header and the HTTP content > It does not have to be a field for every header. The right way to do this would be something like: struct http_header { int type namevalue_pair headers[]; } where namevalue_pair would be something like: namevalue_pair { char *name; char *value; } It does not have to be the same as above, but I hope you get the idea. -- Siddhesh Poyarekar http://siddhesh.in |
From: Philip T. <phi...@gm...> - 2010-07-12 16:23:36
|
>> Thanks for your suggestion, it works now =) >> I cannot check the HTTP status, whether the captcha is correct or wrong, the >> HTTP status is always 301 >> I find the "The document has moved" is to goto the content of the HTTP >> message in order to find if what is sent is right or the URL of a new image. If you just want to know the URL where a 301 sends you, then look for the Location: HTTP header. That's what the HTTP spec says. The content body may not always be there. |
From: Siddhesh P. <sid...@gm...> - 2010-07-13 05:53:52
|
On Mon, Jul 12, 2010 at 9:53 PM, Philip Tellis <phi...@gm...> wrote: >>> Thanks for your suggestion, it works now =) >>> I cannot check the HTTP status, whether the captcha is correct or wrong, the >>> HTTP status is always 301 >>> I find the "The document has moved" is to goto the content of the HTTP >>> message in order to find if what is sent is right or the URL of a new image. > > If you just want to know the URL where a 301 sends you, then look for > the Location: HTTP header. That's what the HTTP spec says. The > content body may not always be there. > Ahh yes, thanks. And that is all the more reason to get some structure around the HTTP headers. -- Siddhesh Poyarekar http://siddhesh.in |
From: kay <ka...@gm...> - 2010-07-17 12:20:04
|
Thanks for your suggestions, I have modified the code and used Location field to find out the URL. 2010/7/13 Philip Tellis <phi...@gm...> >> Thanks for your suggestion, it works now =) > >> I cannot check the HTTP status, whether the captcha is correct or wrong, > the > >> HTTP status is always 301 > >> I find the "The document has moved" is to goto the content of the HTTP > >> message in order to find if what is sent is right or the URL of a new > image. > > If you just want to know the URL where a 301 sends you, then look for > the Location: HTTP header. That's what the HTTP spec says. The > content body may not always be there. > -- --Kay -- --Kay |