Re: http://desyntwww.desy.de/Sub1/page.htm
- Posted by "Thomas Parslow (PatRat)" <tom at almostobsolete.net> Apr 09, 2002
- 518 views
> I don't remember who was asking how to get the error code of the pages, > but well, I can suggest that you use > http://www.rapideuphoria.com/cgi-bin/asearch.exu?keywords=async that > library to get the page an see the error page. > ===== > Best Regards, > Guillermo Bonvehi > AKA: Knixeur - Caballero Rojo If you use asychttp then it would need to be modified a bit to return a status code. Change the DecodeResult procedure to: procedure DecodeResult(integer job) sequence Headers,Body object Code atom loc WsockCloseSocket(Jobs[job][jSOCKET]) Jobs[job][jBUFFER] = ReplaceCRLFs(Jobs[job][jBUFFER]) loc = match("\n\n",Jobs[job][jBUFFER]) if not loc then RaiseError(job) return end if Headers = Jobs[job][jBUFFER][1..loc-1] Body = Jobs[job][jBUFFER][loc+2..length(Jobs[job][jBUFFER])] loc = find('\n',Headers) if loc then Code = Headers[1..loc-1] Headers = Headers[loc+1..length(Headers)] else Code = Headers Headers = "" end if loc = find(' ',Code) if loc then Code = Code[loc+1..length(Code)] loc = find(' ',Code) if loc then Code = Code[1..loc-1] end if Code = value(Code) Code = Code[2] else -- No Code found Code = 0 end if Headers = DecodeHeaders(Headers) loc = sub_find("Transfer-Encoding",Headers,1) if loc then if equal(Headers[loc][2],"chunked") then Body = DecodeChunked(Body) end if end if if asynchttp_onRecieve != -1 then call_proc(asynchttp_onRecieve,{Jobs[job][jURL],Code,Headers,Body}) end if CleanUpJob(job) end procedure The asynchttp_onRecieve event will now have 1 more argument which will be the status code, this is 200 on success 404 on not found 403 on permission denied and so on... The onRecieve event should look like this: procedure onRecieve(sequence url, atom code, sequence headers, sequence body) ? code end procedure Thomas Parslow (PatRat) E-Mail/Jabber: tom at almostobsolete.net ICQ: 26359483