;;;--------------------------------------------------------------------------- ;;; Load the cl-http server and client before ;;; why ? you may ask - for persistent tcp connections, I will reply ;;;--------------------------------------------------------------------------- ;;; (in-package :http) (define invoke-http-service-on-host (host port &rest service-args) "Invokes HTTP service on HOST." (destructuring-bind (method &key continuation url headers) service-args (prog ((n-tries 1) (retry-limit *client-retry-times-for-network-errors*) conn stream) try-again (handler-case-if (and (not *debug-client*) (< n-tries retry-limit)) (unwind-protect (progn (multiple-value-setq (conn stream) (get-connection host port (host-string url))) (with-current-connection (conn) (client-manage-server-response method url headers continuation stream))) ;; critically important to return the connection for a number of platforms. (when conn (return-connection conn) (setq conn nil))) (host-stopped-responding () (incf n-tries) (go try-again)) (network-error (err) (when *client-persistent-connection-report-failures* ;;; ml modif don't do anything ;(report-bug (email-address-for-bug-reports) "Connection Error" "~&Error: ~S~&Description: ~A" (type-of err) (report-string err)) ) (incf n-tries) (process-wait-with-timeout "HTTP Connection Retry" *client-retry-sleep-seconds* #'(lambda () nil)) (go try-again)))))) (defun parse-search-info (url-string &optional (start 0) (end (length url-string))) "Parses the search component of a search URL according to the standard search rules." (declare (values search-keys)) ;; ml ; (print "parse-search-info") ; (print url-string) (let (result) (setf result (unless (= start end) ;no search keys provided (make-url-arg-from-string (subseq url-string start end)) )) ;(print "result of parse-search-info") ;(print result) result )) ;; ml ;; NO CHECKING! UNSAFE! (defun make-url-arg-from-string (s) (let (result (arg-list (geta-strings::list-words s "&")) pair ) (dolist (arg arg-list) (setf pair (geta-strings::list-words arg "=")) (when (consp pair) (setf result (append result (list (list (read-from-string (concatenate 'string ":|" (first pair) "|")) (second pair))))) )) result)) #| (make-url-arg-from-string "args1=3Je+voudrais+de+chambre+pour+deux+nuits&SERVICES=anfr&FORMESORTIE=struct" ) (read-from-string ":|toto|") |# (defun write-search-info-as-query-alist (search-alist &optional (stream *standard-output*) (escape-p *escape-search-urls*)) ;; ml (cond (escape-p (loop for ((keyword value) . alist) = search-alist then alist do (write-string (symbol-name keyword) stream) (write-char #\= stream) (when value (let (;; ml ; (string (http:string-escape-special-chars value)) (string value) ) (write-string string stream))) when alist do (write-char #\& stream) while alist)) (t (loop for ((keyword value) . alist) = search-alist then alist do (write-string (symbol-name keyword) stream) (write-char #\= stream) (when value (write-string value stream)) when alist do (write-char #\& stream) while alist)))) ;; end of file