From 004957bcd6a7069335ff89b7ca5f2384f49422d0 Mon Sep 17 00:00:00 2001 From: Jay McCarthy Date: Wed, 16 Apr 2014 12:30:11 -0600 Subject: [PATCH] Add FAQ section --- .../net-doc/net/scribblings/http-client.scrbl | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/pkgs/net-pkgs/net-doc/net/scribblings/http-client.scrbl b/pkgs/net-pkgs/net-doc/net/scribblings/http-client.scrbl index 533042c685..5ec9e41c4d 100644 --- a/pkgs/net-pkgs/net-doc/net/scribblings/http-client.scrbl +++ b/pkgs/net-pkgs/net-doc/net/scribblings/http-client.scrbl @@ -141,3 +141,23 @@ response, which is why there is no @racket[#:closed?] argument like } +@section[#:tag "faq"]{Troubleshooting and Tips} + +@subsection{How do I send properly formatted POST form requests?} + +You should send a @litchar{Content-Type} header with the value +@litchar{application/x-www-form-urlencoded} and send the data +formatted by @racketmodname[net/uri-codec]'s +@racket[form-urlencoded-encode] function. For example, + +@(require (for-label net/uri-codec)) +@racketblock[ +(http-send! + hc "/login" + #:method "POST" + #:data + (alist->form-urlencoded + (list (cons 'username "Ryu") + (cons 'password "Sheng Long"))) + #:headers (list "Content-Type: application/x-www-form-urlencoded")) +]