30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
-
+
|
(defun elisp-http-get-line ()
(let* ((_path (elisp-http-prompt-api))
(path (format "GET /%s HTTP/1.1" _path)))
path))
;;;(elisp-http-register-line)
(defun elisp-http-make-content (method)
(defun elisp-http-make-content ()
(let ((request-line (elisp-http-set-request-line)))
(concat
request-line "\n"
(mapconcat (lambda (x)
(format "%s: %s" (car x) (cdr x)))
my-headers
"\n"))))
|
60
61
62
63
64
65
66
|
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
"\n")))
(concat request-line "\n"
header-block "\n\n"
json-body)))
;; Пример использования:
;;;(elisp-http-register-content)
(defun elisp-http-login-content ()
"Generate HTTP request content for login with JSON payload using 'email'."
(let* ((email (elisp-http-prompt-email))
(password (elisp-http-prompt-password))
(request-line (format "POST /%s HTTP/1.1" (elisp-http-prompt-api)))
(json-body (json-encode `(("email" . ,email) ("password" . ,password))))
(headers (append my-headers
(list (cons "Content-Length"
(number-to-string (string-bytes json-body))))))
(header-block
(mapconcat (lambda (x) (format "%s: %s" (car x) (cdr x)))
headers
"\n")))
(concat request-line "\n"
header-block "\n\n"
json-body)))
;;;(elisp-http-login-content)
;;;(setq youo (elisp-http-login-content))
;;; "email": "somex@gmail.com",
;;; "password": "test1234"
|