http-client post pasted by mario-goulart on Mon Feb 25 20:06:21 2013
;;; ;;; client ;;; (use http-client uri-common intarweb) (define data "foobar") (call-with-response (make-request uri: (uri-reference "http://localhost:8080/echo-service") method: 'POST (headers `((content-type text/plain) (content-length ,(string-length data))))) (lambda (req) (let ((port (request-port req))) (display data port) (flush-output port))) #f) ;;; ;;; server ;;; (use awful) (define-page "/echo-service" (lambda () (with-request-variables (data) (print "-----------------") (print data) (->string data))) method: 'post)
ugh (it works now) added by mario-goulart on Mon Feb 25 20:30:36 2013
;;; ;;; client ;;; (use http-client uri-common intarweb) (define data "foobar") (call-with-response (make-request uri: (uri-reference "http://localhost:8080/echo-service") method: 'POST headers: (headers `((content-type text/plain) (content-length ,(string-length data))))) (lambda (req) (let ((port (request-port req))) (display data port) (flush-output port))) void) ;;; ;;; server ;;; (use awful intarweb spiffy) (define-page "/echo-service" (lambda () (let* ((req (current-request)) (headers (request-headers (current-request))) (content-length (header-value 'content-length headers))) (cond ((and content-length (zero? content-length)) #f) ((not content-length) (error 'echo-service "Set content-length, sloppy client")) (else (let ((data (read-string content-length (request-port req)))) (print "-----------------") (print data) (->string data)))))) method: 'post)