speed feeds refresh up by using http headers

This commit is contained in:
Athou
2013-04-17 12:49:03 +02:00
parent 328aa8c019
commit ef3508f393
7 changed files with 150 additions and 25 deletions

View File

@@ -20,6 +20,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.commafeed.backend.HttpGetter;
import com.commafeed.backend.HttpGetter.HttpResult;
import com.commafeed.backend.StartupBean;
import com.commafeed.backend.model.UserRole.Role;
import com.commafeed.frontend.SecurityCheck;
@@ -74,7 +75,10 @@ public class FaviconPage extends BasePage {
String iconUrl = "http://g.etfv.co/"
+ URLEncoder.encode(url, "UTF-8") + "?defaulticon=none";
img = getter.getBinary(iconUrl);
HttpResult result = getter.getBinary(iconUrl);
if (result != null) {
img = result.getContent();
}
}
} catch (Exception e) {
log.error(e.getMessage(), e);

View File

@@ -3,7 +3,6 @@ package com.commafeed.frontend.rest.resources;
import java.lang.reflect.Method;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import javax.inject.Inject;
import javax.interceptor.AroundInvoke;
import javax.interceptor.InvocationContext;

View File

@@ -21,6 +21,7 @@ import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.ObjectUtils;
import org.apache.commons.lang.StringUtils;
import com.commafeed.backend.model.Feed;
import com.commafeed.backend.model.FeedCategory;
@@ -42,11 +43,11 @@ public class SubscriptionsREST extends AbstractREST {
@ApiOperation(value = "Fetch a feed", notes = "Fetch a feed by its url", responseClass = "com.commafeed.backend.model.Feed")
public Feed fetchFeed(@QueryParam("url") String url) {
Preconditions.checkNotNull(url);
url = StringUtils.trimToEmpty(url);
url = prependHttp(url);
Feed feed = null;
try {
feed = feedFetcher.fetch(url, true);
feed = feedFetcher.fetch(url, true, null, null);
} catch (Exception e) {
throw new WebApplicationException(e, Response
.status(Status.INTERNAL_SERVER_ERROR)