开发者

Recursive HTTP request: How to prevent a page from calling itself

I'm looking for a good way to prevent the scenario of the page calling itself repeatedly.

I have a page, that to be rendered needs to make an HTTP request to an RSS feed. If the URL to that RSS feed happens to be the current page, it will fire off a request to itself. The new request would start off another request to the page, which would start another request... This continues until the site grinds to a halt when all available connections are busy in this recursive loop.

A few notes:

  • The URL to the RSS is entered by the user.
  • This is a page in a CMS, the URL of the page could be almost anything and could change after the RSS URL is entered.
  • In this case, the user entered a URL to a remote server that lead to a redirect back to the page.

A few ideas:

  1. I could just deny all requests from the localhost IP before rendering.

  2. Before sending the request, I could track in a common location which requests are active and not even send it if it's already in the middle of another request to the same address.

  3. Maybe add a custom user-agent to the request header and deny the request if that u开发者_开发百科ser agent is seen?


Does the page being rendered know it's own address/URL (it should), if so can't it just check to ensure it's address doesn't match the RSS one?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜