[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 07/119: TODO: handle post data
From: |
Eric Schulte |
Subject: |
[elpa] 07/119: TODO: handle post data |
Date: |
Mon, 10 Mar 2014 16:56:58 +0000 |
eschulte pushed a commit to branch master
in repository elpa.
commit 9b1b31221f1a4f3aec1038a2033c06858ad80172
Author: Eric Schulte <address@hidden>
Date: Wed Dec 18 01:25:22 2013 -0700
TODO: handle post data
---
emacs-web-server-test.el | 23 +++++++++++++++++++++++
emacs-web-server.el | 18 ++++++++++++++----
2 files changed, 37 insertions(+), 4 deletions(-)
diff --git a/emacs-web-server-test.el b/emacs-web-server-test.el
index 1e5e718..f5aa9c3 100644
--- a/emacs-web-server-test.el
+++ b/emacs-web-server-test.el
@@ -29,3 +29,26 @@
(ert-deftest ews/parse-many-headers ()
"Test that a number of headers parse successfully."
(should t))
+
+(ert-deftest ews/parse-post-data ()
+ (let ((post-header
+ "POST / HTTP/1.1
+User-Agent: curl/7.33.0
+Host: localhost:8080
+Accept: */*
+Content-Length: 273
+Expect: 100-continue
+Content-Type: multipart/form-data; boundary=----------------f1270d0deb77af03
+
+------------------f1270d0deb77af03
+Content-Disposition: form-data; name=\"date\"
+
+Wed Dec 18 00:55:39 MST 2013
+
+------------------f1270d0deb77af03
+Content-Disposition: form-data; name=\"name\"
+
+\"schulte\"
+------------------f1270d0deb77af03--
+"))
+ (should 'properly-parse-post-data)))
diff --git a/emacs-web-server.el b/emacs-web-server.el
index 98530cd..461d012 100644
--- a/emacs-web-server.el
+++ b/emacs-web-server.el
@@ -8,6 +8,7 @@
;;; Code:
(require 'emacs-web-server-status-codes)
+(require 'mail-parse)
(require 'eieio)
(require 'cl-lib)
@@ -98,22 +99,31 @@ function.
(:otherwise (message "[ews] bad header: %S" string) nil)))
(defun ews-filter (proc string)
+ ;; TODO: parse post DATA, see the relevent test, and use these
+ ;; - mail-header-parse-content-disposition
+ ;; - mail-header-parse-content-type
(with-slots (handler clients) (plist-get (process-plist proc) :server)
;; register new client
(unless (assoc proc clients) (push (list proc "") clients))
(let* ((client (assoc proc clients)) ; clients are (proc pending headers)
(pending (concat (cadr client) string))
- (last-index 0) index)
+ (last-index 0) index in-post)
(catch 'finished-parsing-headers
;; parse headers and append to client
(while (setq index (string-match "\r\n" pending last-index))
- (when (= last-index index) ; double \r\n, done headers, call handler
+ ;; double \r\n outside of post data -> done w/headers, call handler
+ (when (and (not in-post) (= last-index index))
(throw 'finished-parsing-headers
(when (ews-call-handler proc (cddr client) handler)
(setq clients (assq-delete-all proc clients))
(delete-process proc))))
- (setcdr (last client)
- (ews-parse (substring pending last-index index)))
+ (if in-post
+ ;; build up post data, maybe set in-post to boundary
+ (error "TODO: handle POST data")
+ (let ((this (ews-parse (substring pending last-index index))))
+ (if (eql (caar this) :CONTENT-TYPE)
+ (error "TODO: handle POST data")
+ (setcdr (last client) this))))
(setq last-index (+ index 2)))
(setcar (cdr client) (substring pending last-index))))))
- [elpa] branch master updated (f64a801 -> 4f28097), Eric Schulte, 2014/03/10
- [elpa] 02/119: logging support, Eric Schulte, 2014/03/10
- [elpa] 03/119: parsing HTTP headers, Eric Schulte, 2014/03/10
- [elpa] 01/119: initial commit, echo server working, Eric Schulte, 2014/03/10
- [elpa] 04/119: simple hello world server working, Eric Schulte, 2014/03/10
- [elpa] 05/119: stub out (but don't write any) tests, Eric Schulte, 2014/03/10
- [elpa] 08/119: NOTES file for tasks and notes, Eric Schulte, 2014/03/10
- [elpa] 07/119: TODO: handle post data,
Eric Schulte <=
- [elpa] 06/119: helper for HTTP headers, Eric Schulte, 2014/03/10
- [elpa] 09/119: parsing form data in POST, Eric Schulte, 2014/03/10
- [elpa] 11/119: more flexible network process creation, Eric Schulte, 2014/03/10
- [elpa] 10/119: some simple examples, Eric Schulte, 2014/03/10
- [elpa] 15/119: more lenient parsing of multipart forms, Eric Schulte, 2014/03/10
- [elpa] 12/119: compiling to .elc, Eric Schulte, 2014/03/10
- [elpa] 13/119: tasks, Eric Schulte, 2014/03/10
- [elpa] 18/119: 404 not found helper, Eric Schulte, 2014/03/10
- [elpa] 17/119: handling errors, Eric Schulte, 2014/03/10
- [elpa] 14/119: better requirements for test, Eric Schulte, 2014/03/10