          (port (process-contact p :service)))
     (when p (delete-process p))
     (unless port
-      (error "Could not retrive unused localhost port"))
+      (error "Could not retrieve unused localhost port"))
     port))
 
 (defun ycmd--exit-code-as-string (code)

ycmd server to stop.  If the ycmd server is still running after a
timeout specified by `ycmd-delete-process-delay', then kill the
process with `delete-process'."
  (condition-case nil
      (let ((start-time (float-time)))
        (ycmd--request "/shutdown" nil :parser 'json-read :sync t)
        (while (and (ycmd-running?)
                    (> ycmd-delete-process-delay
                       (- (float-time) start-time)))
          (sit-for 0.05))
        (delete-process ycmd--server-process-name))
    (error nil)))

(defun ycmd-running? ()
  "Return t if a ycmd server is already running."

         (response-fn (lambda (response)
                        (let ((data (request-response-data response)))
                          (ycmd--log-content "HTTP RESPONSE CONTENT" data)
                          data)))
         (request-args (list :type type :params params :data content
                             :parser parser :headers headers
                             :timeout timeout)))
    (ycmd--log-content "HTTP REQUEST CONTENT" content)

    (if sync
        (let* (result
               (cb (cl-function
                    (lambda (&key response &allow-other-keys)
                      (setq result (funcall response-fn response))))))
          (with-local-quit
            (apply #'request url :sync t :complete cb request-args))
          result)
      (deferred:$
        (apply #'request-deferred url request-args)
        (deferred:nextc it response-fn)))))

(provide 'ycmd)

