anchor.diff:      {noreply, State}.
   
   handle_info({rss_update}, State) ->
  -	process_rss(State),
  -	erlang:send_after(State#state.repeat_time, self(), {rss_update}),
  -	{noreply, State};
  +	NewState = process_rss(State),
  +	?INFO("New state: ~p", [NewState]),
  +	erlang:send_after(NewState#state.repeat_time, self(), {rss_update}),
  +	{noreply, NewState};
   
   handle_info(_Info, State) ->
       {noreply, State}.
  
positive.code:     {ok, State}.
  
  
  %% private functions
  
  process_rss(State) ->
  	Url = State#state.url,
  	?INFO("Fetching RSS update for URL ~p", [Url]),
  	
  	% TODO: add support for expiration headers (If-None-Match/ETag and If-Modified-Since/Last-Modified)
  	% synchronous download of RSS feed
  	{ok, {{_Version, 200, _ReasonPhrase}, _Headers, Body}} = 
  		httpc:request(get, {Url, []}, [], []),
  	?INFO("Got RSS body of length ~p for Url ~p", [length(Body), Url]),
  	
  	{ok, Items} = snp_rss_parse:get_items(Body),
  	
  	lists:map(fun(Item) -> 
  
negative.code: 					  snp_article_parser_server:create(Item, StartDelay) 
  			  end, Items),
  	ok.
  
  
  extract_etag(Headers) ->
  	case lists:keyfind("etag", 1, Headers) of
  		{_, ETag} -> ETag;
  		false -> none
  	end.
  
  extract_last_modified(Headers) ->
  	case lists:keyfind("last-modified", 1, Headers) of
  		{_, LastModified} -> LastModified;
  		false -> none
  	end.
  
  
  get_etag_header(#state{etag=none}) -> []; 
  get_etag_header(#state{etag=ETag}) when is_list(ETag) ->
  	[{"If-None-Match", ETag}].
  	
  get_last_modified_header(#state{last_modified=none}) -> [];
  get_last_modified_header(#state{last_modified=LastModified}) 
    when is_list(LastModified) -> [{"If-Modified-Since", LastModified}].
  
  	
  %% --------------------------------------------------------------------
  %%% Unit tests
  %% --------------------------------------------------------------------
  
  
  -ifdef(TEST).
  
  get_etag_headers_none_test() ->
  	State = #state{etag=none},
  	Headers = get_etag_header(State),
  	?assertEqual([], Headers).
  
  get_etag_headers_test() ->
  	State = #state{etag=45},
  	?assertError(function_clause, get_etag_header(State)).
  
  extract_etag_test() ->
  	Headers = [{"Header1", "val1"}, {"etag", "etag-val"}, {"Header2", "val3"}],
  	ETag = extract_etag(Headers),
  	?assertEqual("etag-val", ETag).
  
  extract_etag_not_found_test() ->
  	Headers = [{"Header1", "val1"}, {"Header2", "val3"}],
  	ETag = extract_etag(Headers),
  	?assertEqual(none, ETag).	
  	
  
  -endif.