From 7c844909b98dc441726160c5e6b505a646e8fd5d Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Wed, 6 May 2015 11:14:02 -0600 Subject: [PATCH] fastcgi: Add support for OPTIONS requests --- middleware/fastcgi/fastcgi.go | 2 ++ middleware/fastcgi/fcgiclient.go | 11 ++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/middleware/fastcgi/fastcgi.go b/middleware/fastcgi/fastcgi.go index e797f43d1..6d7fd1f88 100644 --- a/middleware/fastcgi/fastcgi.go +++ b/middleware/fastcgi/fastcgi.go @@ -70,6 +70,8 @@ func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error) resp, err = fcgi.Head(env) case "GET": resp, err = fcgi.Get(env) + case "OPTIONS": + resp, err = fcgi.Options(env) case "POST": resp, err = fcgi.Post(env, r.Header.Get("Content-Type"), r.Body, contentLength) case "PUT": diff --git a/middleware/fastcgi/fcgiclient.go b/middleware/fastcgi/fcgiclient.go index a1cd35e50..3e223d876 100644 --- a/middleware/fastcgi/fcgiclient.go +++ b/middleware/fastcgi/fcgiclient.go @@ -416,7 +416,16 @@ func (this *FCGIClient) Head(p map[string]string) (resp *http.Response, err erro return this.Request(p, nil) } -// Get issues a Post request to the fcgi responder. with request body +// Options issues an OPTIONS request to the fcgi responder. +func (this *FCGIClient) Options(p map[string]string) (resp *http.Response, err error) { + + p["REQUEST_METHOD"] = "OPTIONS" + p["CONTENT_LENGTH"] = "0" + + return this.Request(p, nil) +} + +// Post issues a POST request to the fcgi responder. with request body // in the format that bodyType specified func (this *FCGIClient) Post(p map[string]string, bodyType string, body io.Reader, l int) (resp *http.Response, err error) {