Skip to content

Instantly share code, notes, and snippets.

@miya2000
Created February 5, 2011 03:40
Show Gist options
  • Select an option

  • Save miya2000/812179 to your computer and use it in GitHub Desktop.

Select an option

Save miya2000/812179 to your computer and use it in GitHub Desktop.
var GOOGLE_READER_PROXY_URL = 'http://www.google.com/reader/atom/feed/'
function feedRequest(href, feedCallback) {
httpRequest(href, callback);
function callback(e) {
if (e.status == '403') {
postError('feed access denied. [' + e.status + '] ' + e.statusText);
if (href.indexOf(GOOGLE_READER_PROXY_URL) != 0) {
var url = GOOGLE_READER_PROXY_URL + encodeURIComponent(href);
postError('retry to Google Reader [' + url + ']');
feedRequest(url, feedCallback);
return;
}
}
if (e.readyState < 4) { // timeout.
var feedObj = {
title : href,
link : href,
description: NDR.lang.ABORTED_CONNECTION,
items : [],
url : href,
status : 'timeout'
};
}
else if (e.responseText == "") {
var feedObj = {
title : href,
link : href,
description: NDR.lang.MISSING_DATA,
items : [],
url : href,
status : 'nodata'
};
}
else if (!/^\s*</.test(e.responseText)) { // deleted mylist. etc.
var feedObj = {
title : href,
link : href,
description: NDR.lang.INVALID_FEED + '\n(' + /\s*(.*)$/m.exec(e.responseText)[0].substring(0, 300) + ')',
items : [],
url : href,
status : 'invalid'
};
}
else {
var feedObj = parseFeedObjectFromString(e.responseText);
feedObj.url = href;
feedObj.status = 'ok';
if (!feedObj.link) {
feedObj.link = href;
}
}
feedCallback(feedObj);
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment