 (defn- crawler-client-context []
   ;; Automatically follow HTTP redirects
   (doto (Context.)
-    (.. getParameters (add "followRedirects" "true"))))
+    (.. getParameters (add "followRedirects" "false"))))
 
 (def #^{:private true} crawler-http-client
      ;; Client is thread-safe.

(ns org.altlaw.util.crawler
  (:require [org.altlaw.db.download-log :as dl]
            [clojure.contrib.singleton :as sing]
            [clojure.contrib.java-utils :as j])
  (:import (org.restlet Client Context)

  (merge (basic-response-map response)
         (extended-response-map response)))

(declare handle-download-request)

(defn- handle-redirect [result]
  (let [code (:response_status_code result)
        headers (into {} (:response_headers result))
        location (get headers "Location")
        original-request (select-keys result [:request_form_fields
                                              :request_headers])
        new-request (assoc original-request :request_uri location)]
    (log/warn "HTTP response " code " to " (pr-str original-request))
    (assoc (handle-download-request new-request) :redirect_from result)))

(defn- execute-request
  "Calls the client to handle the request, logs the URL in the
  download log, and returns the download record as a keyword=>value
