Brion Vibber wrote:
Jim Higson wrote:
How can I check if a page exists from a program?
You can hit Special:Export/Pagename; if the response contains no <page> elements, the page does not exist.
I've tried doing a HEAD request to the page url with &action=raw, but that returns 200 regardless if the page exists (bug or feature?).
You get a 200 because the wiki script exists, and hasn't yet been special cased to return a 404 response for pages which don't exist.
The only way I can find at the moment is the Date and Last-Modified response headers are the same if the article doesn't exist yet, but this seems a bit too hackish.
[...]
Oops, actually the Last-Modified header is always one hour (to the second) before Date if the article doesn't exist.
I can't reproduce this; for pages that don't exist there is no Last-Modified header at all. Can you show a sample request and returned headers?
My 'application' uses XMLHTTP to make the request from a web page. Since this can only be made from a page on the same domain I put up a quick example:
Visit this in a recent version of Mozilla or similar and it should spit the headers to the page.
Jim