Tests: goftm used for Go applications.
This commit is contained in:
@@ -1,22 +1,22 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"nginx/unit"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"nginx/unit"
|
||||
)
|
||||
|
||||
func handler(w http.ResponseWriter, r *http.Request) {
|
||||
b, e := ioutil.ReadFile("404.html")
|
||||
b, e := ioutil.ReadFile("404.html")
|
||||
|
||||
if e == nil {
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
io.WriteString(w, string(b))
|
||||
}
|
||||
if e == nil {
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
io.WriteString(w, string(b))
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
http.HandleFunc("/", handler)
|
||||
unit.ListenAndServe(":7080", nil)
|
||||
http.HandleFunc("/", handler)
|
||||
unit.ListenAndServe(":7080", nil)
|
||||
}
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"io"
|
||||
"os"
|
||||
"fmt"
|
||||
"strings"
|
||||
"net/http"
|
||||
"nginx/unit"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"nginx/unit"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func handler(w http.ResponseWriter, r *http.Request) {
|
||||
args := strings.Join(os.Args[1:], ",")
|
||||
args := strings.Join(os.Args[1:], ",")
|
||||
|
||||
w.Header().Add("X-Arg-0", fmt.Sprintf("%v", os.Args[0]))
|
||||
w.Header().Add("Content-Length", fmt.Sprintf("%v", len(args)))
|
||||
io.WriteString(w, args)
|
||||
w.Header().Add("X-Arg-0", fmt.Sprintf("%v", os.Args[0]))
|
||||
w.Header().Add("Content-Length", fmt.Sprintf("%v", len(args)))
|
||||
io.WriteString(w, args)
|
||||
}
|
||||
|
||||
func main() {
|
||||
http.HandleFunc("/", handler)
|
||||
unit.ListenAndServe(":7080", nil)
|
||||
http.HandleFunc("/", handler)
|
||||
unit.ListenAndServe(":7080", nil)
|
||||
}
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"nginx/unit"
|
||||
"net/http"
|
||||
"nginx/unit"
|
||||
)
|
||||
|
||||
func handler(w http.ResponseWriter, r *http.Request) {
|
||||
cookie1, _ := r.Cookie("var1")
|
||||
cookie2, _ := r.Cookie("var2")
|
||||
cookie1, _ := r.Cookie("var1")
|
||||
cookie2, _ := r.Cookie("var2")
|
||||
|
||||
w.Header().Set("X-Cookie-1", cookie1.Value)
|
||||
w.Header().Set("X-Cookie-2", cookie2.Value)
|
||||
w.Header().Set("X-Cookie-1", cookie1.Value)
|
||||
w.Header().Set("X-Cookie-2", cookie2.Value)
|
||||
}
|
||||
|
||||
func main() {
|
||||
http.HandleFunc("/", handler)
|
||||
unit.ListenAndServe(":7080", nil)
|
||||
http.HandleFunc("/", handler)
|
||||
unit.ListenAndServe(":7080", nil)
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"nginx/unit"
|
||||
"net/http"
|
||||
"nginx/unit"
|
||||
)
|
||||
|
||||
func handler(w http.ResponseWriter, r *http.Request) {}
|
||||
|
||||
func main() {
|
||||
http.HandleFunc("/", handler)
|
||||
unit.ListenAndServe(":7080", nil)
|
||||
http.HandleFunc("/", handler)
|
||||
unit.ListenAndServe(":7080", nil)
|
||||
}
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"nginx/unit"
|
||||
"net/http"
|
||||
"nginx/unit"
|
||||
)
|
||||
|
||||
func handler(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("X-Var-1", r.URL.Query().Get("var1"))
|
||||
w.Header().Set("X-Var-2", r.URL.Query().Get("var2"))
|
||||
w.Header().Set("X-Var-3", r.URL.Query().Get("var3"))
|
||||
w.Header().Set("X-Var-1", r.URL.Query().Get("var1"))
|
||||
w.Header().Set("X-Var-2", r.URL.Query().Get("var2"))
|
||||
w.Header().Set("X-Var-3", r.URL.Query().Get("var3"))
|
||||
}
|
||||
|
||||
func main() {
|
||||
http.HandleFunc("/", handler)
|
||||
unit.ListenAndServe(":7080", nil)
|
||||
http.HandleFunc("/", handler)
|
||||
unit.ListenAndServe(":7080", nil)
|
||||
}
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"io"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"nginx/unit"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"nginx/unit"
|
||||
)
|
||||
|
||||
func handler(w http.ResponseWriter, r *http.Request) {
|
||||
var buf [32768]byte;
|
||||
len, _ := r.Body.Read(buf[:])
|
||||
var buf [32768]byte
|
||||
len, _ := r.Body.Read(buf[:])
|
||||
|
||||
w.Header().Add("Content-Length", fmt.Sprintf("%v", len))
|
||||
io.WriteString(w, string(buf[:len]))
|
||||
w.Header().Add("Content-Length", fmt.Sprintf("%v", len))
|
||||
io.WriteString(w, string(buf[:len]))
|
||||
}
|
||||
|
||||
func main() {
|
||||
http.HandleFunc("/", handler)
|
||||
unit.ListenAndServe(":7080", nil)
|
||||
http.HandleFunc("/", handler)
|
||||
unit.ListenAndServe(":7080", nil)
|
||||
}
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"nginx/unit"
|
||||
"net/http"
|
||||
"nginx/unit"
|
||||
)
|
||||
|
||||
func handler(w http.ResponseWriter, r *http.Request) {
|
||||
r.ParseForm()
|
||||
r.ParseForm()
|
||||
|
||||
w.Header().Set("X-Var-1", r.Form.Get("var1"))
|
||||
w.Header().Set("X-Var-2", r.Form.Get("var2"))
|
||||
w.Header().Set("X-Var-3", r.Form.Get("var3"))
|
||||
w.Header().Set("X-Var-1", r.Form.Get("var1"))
|
||||
w.Header().Set("X-Var-2", r.Form.Get("var2"))
|
||||
w.Header().Set("X-Var-3", r.Form.Get("var3"))
|
||||
}
|
||||
|
||||
func main() {
|
||||
http.HandleFunc("/", handler)
|
||||
unit.ListenAndServe(":7080", nil)
|
||||
http.HandleFunc("/", handler)
|
||||
unit.ListenAndServe(":7080", nil)
|
||||
}
|
||||
|
||||
@@ -1,30 +1,30 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"io"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"nginx/unit"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"nginx/unit"
|
||||
)
|
||||
|
||||
func handler(w http.ResponseWriter, r *http.Request) {
|
||||
var buf [4096]byte;
|
||||
len, _ := r.Body.Read(buf[:])
|
||||
var buf [4096]byte
|
||||
len, _ := r.Body.Read(buf[:])
|
||||
|
||||
w.Header().Set("Request-Method", r.Method)
|
||||
w.Header().Set("Request-Uri", r.RequestURI)
|
||||
w.Header().Set("Server-Protocol", r.Proto)
|
||||
w.Header().Set("Server-Protocol-Major", fmt.Sprintf("%v", r.ProtoMajor))
|
||||
w.Header().Set("Server-Protocol-Minor", fmt.Sprintf("%v", r.ProtoMinor))
|
||||
w.Header().Set("Content-Length", fmt.Sprintf("%v", len))
|
||||
w.Header().Set("Content-Type", r.Header.Get("Content-Type"))
|
||||
w.Header().Set("Custom-Header", r.Header.Get("Custom-Header"))
|
||||
w.Header().Set("Http-Host", r.Header.Get("Host"))
|
||||
w.Header().Set("Request-Method", r.Method)
|
||||
w.Header().Set("Request-Uri", r.RequestURI)
|
||||
w.Header().Set("Server-Protocol", r.Proto)
|
||||
w.Header().Set("Server-Protocol-Major", fmt.Sprintf("%v", r.ProtoMajor))
|
||||
w.Header().Set("Server-Protocol-Minor", fmt.Sprintf("%v", r.ProtoMinor))
|
||||
w.Header().Set("Content-Length", fmt.Sprintf("%v", len))
|
||||
w.Header().Set("Content-Type", r.Header.Get("Content-Type"))
|
||||
w.Header().Set("Custom-Header", r.Header.Get("Custom-Header"))
|
||||
w.Header().Set("Http-Host", r.Header.Get("Host"))
|
||||
|
||||
io.WriteString(w, string(buf[:len]))
|
||||
io.WriteString(w, string(buf[:len]))
|
||||
}
|
||||
|
||||
func main() {
|
||||
http.HandleFunc("/", handler)
|
||||
unit.ListenAndServe(":7080", nil)
|
||||
http.HandleFunc("/", handler)
|
||||
unit.ListenAndServe(":7080", nil)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user