/*
- * Copyright 2001-2009 Internet2
+ * Copyright 2001-2010 Internet2
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* @return true iff the header is successfully set
*/
virtual bool setRequestHeader(const char* name, const char* value)=0;
+
+ /**
+ * Controls redirect behavior.
+ *
+ * @param follow true iff Location-based redirects should be honored
+ * @param maxRedirs maximum number of redirects to permit
+ */
+ virtual bool followRedirects(bool follow, unsigned int maxRedirs);
/**
* Returns the values of an HTTP response header.
return true;
}
+ bool followRedirects(bool follow, unsigned int maxRedirs) {
+ return (
+ curl_easy_setopt(m_handle, CURLOPT_FOLLOWLOCATION, (follow ? 1 : 0)) == CURLE_OK &&
+ curl_easy_setopt(m_handle, CURLOPT_MAXREDIRS, (follow ? maxRedirs : 0)) == CURLE_OK
+ );
+ }
+
bool setCacheTag(string* cacheTag) {
m_cacheTag = cacheTag;
return true;