anchor.diff:               (docker-protocol-error-reason condition)))))
   
   
  +;;; If it is non-NIL, the communication with the Docker daemon will be
  +;;; logged into the standard output.
  +(defvar *debug-protocol* nil)
  +
  +;;; Like `read-line', but it trims trailing CR and LF character as
  +;;; well as support for logging for debugging purposes.
  +(defun read-line* (stream &optional (eof-error-p t))
  +  (let ((line (string-right-trim *crlf* (read-line stream eof-error-p))))
  +    (when *debug-protocol*
  +      (format t "~a~%" line))
  +    line))
  +
  +;;; Like `format', but support logging for debugging purposes.
  +(defun format* (stream fmt &rest args)
  +  (when *debug-protocol*
  +    (format t "~?~%" fmt args))
  +  (apply #'format stream fmt args))
  +
  +;;; Write a CR and a LF character to STREAM.
  +(defun write-crlf (stream)
  +  (write-string *crlf* stream))
  +
  +(defun format-line* (stream fmt &rest args)
  +  (apply #'format* stream fmt args)
  +  (write-crlf stream))
  +
  +
  +(defun transfer-coding (headers)
  +  (let ((value (cdr (assoc :transfer-encoding headers))))
  +    (when value
  +      (subseq value 0 (or (position #\; value) (length value))))))
  +
  +;;; Check if STREAM is a input binary stream.
  +(defun binary-input-stream-p (stream)
  +  (and (input-stream-p stream)
  +       (equal (stream-element-type stream) '(unsigned-byte 8))))
  +
   (defun parse-status-line (line)
     ;; HTTP-Version SP Status-Code SP Reason-Phrase CRLF
     (let* ((sp1 (position #\space line))
  
positive.code:   (let ((stream (open-docker-stream)))
      ;; Request resource
      (format* stream "~a ~a HTTP/1.1" method url)
      (write-crlf stream)
      (write-crlf stream)
      (finish-output stream)
  
      ;; Process response
      (let ((status-line (read-line* stream)))
  
negative.code:         (yason:parse stream
                       :object-key-fn #'string-to-keyword
                       :object-as :plist)))))
  
  
  (defun query-string (&rest plist)
    (with-output-to-string (out)
      (let ((plist (loop
                      for (x y) on plist by #'cddr
                      unless (null y)
                      collect x
                      collect y)))
        (when plist
          (destructuring-bind (attr value &rest others) plist
            (declare (ignore others))
            (format out "?~a=~a" attr value)))
        (loop
           for (attr value) on (cddr plist) by #'cddr
           do (format out "&~a=~a" attr value)))))
  