cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: feature suggestion (with patch): callback function on http redirects

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Sun, 15 Jan 2012 23:44:35 +0100 (CET)

On Sun, 15 Jan 2012, Jochen Kornitzky wrote:

> you may want to consider the attached patch implementing a callback function
> in libcurl to be called when a http redirect (enabled by
> CURLOPT_FOLLOWLOCATION) is about to be followed. The callback function is
> called with the URL to be opened and may abort the redirect by returning an
> error code.

Hi Jochen and thanks a lot for your contribution and desire to help us improve
libcurl!

I'm however not very keen to add this feature - not only because we're in a
feature freeze right now, but also more general. Let me elaborate:

In libcurl we provide a rather simple and "crude" follow-HTTP-redirects when
enabled. This is designed to allow programs that just want to follow redirects
in a simple-minded and straight forward way. It was never meant to be advanced
and we have since day one argued that any program that needs more advanced
redirect handling should do it themselves. For this reason we also implemented
CURLINFO_REDIRECT_URL a few years ago.

Using that info variable, it is very easy for a program to loop around
requests and do all the redirect logic themselves. It can then apply and use
all sorts of logic, comparisons and filters and what not. I would argue that
this is even much more powerful than the callback approach your patch enables,
and yet it will not require a lot more extra code in the program for the
simple cases.

So, you would have to argue why your approach is needed when the simple
function is already there and advanced redirect handling is offered too. Why
would we need a third?

-- 
  / daniel.haxx.se
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2012-01-15