   (with-current-buffer (or buffer (current-buffer))
     (let* ((column-num (+ 1 (ycmd--column-in-bytes)))
            (line-num (line-number-at-pos (point)))
-           (full-path (or (buffer-file-name) ""))
-           (file-contents (buffer-substring-no-properties (point-min) (point-max)))
+           (full-path (ycmd--encode-string (or (buffer-file-name) "")))
+           (file-contents (ycmd--encode-string
+                           (buffer-substring-no-properties
+                            (point-min) (point-max))))
            (file-types (or (ycmd-major-mode-to-file-types major-mode)
                            '("generic"))))
       `(("file_data" .

  (- (position-bytes (point))
     (position-bytes (line-beginning-position))))

(defun ycmd--standard-content (&optional buffer)
  "Generate the 'standard' content for ycmd posts.



(defun ycmd--get-request-hmac (method path body)
  "Generate HMAC for request from METHOD, PATH and BODY."
  (ycmd--hmac-function
   (mapconcat (lambda (val)
                (ycmd--hmac-function
                 (ycmd--encode-string val) ycmd--hmac-secret))
              `(,method ,path ,(or body "")) "")
   ycmd--hmac-secret))

(defun* ycmd--request (location
                       content
