mirror of
https://gitee.com/johng/gf
synced 2026-06-07 02:12:11 +08:00
ghttp updates
This commit is contained in:
@ -19,7 +19,7 @@ import (
|
||||
|
||||
// 请求对象
|
||||
type Request struct {
|
||||
http.Request
|
||||
*http.Request
|
||||
parsedGet bool // GET参数是否已经解析
|
||||
parsedPost bool // POST参数是否已经解析
|
||||
queryVars map[string][]string // GET参数
|
||||
@ -46,7 +46,7 @@ func newRequest(s *Server, r *http.Request, w http.ResponseWriter) *Request {
|
||||
routerVars : make(map[string][]string),
|
||||
Id : s.servedCount.Add(1),
|
||||
Server : s,
|
||||
Request : *r,
|
||||
Request : r,
|
||||
Response : newResponse(s, w),
|
||||
EnterTime : gtime.Microsecond(),
|
||||
}
|
||||
@ -59,7 +59,7 @@ func newRequest(s *Server, r *http.Request, w http.ResponseWriter) *Request {
|
||||
|
||||
// 获取Web Socket连接对象(如果是非WS请求会失败,注意检查然会的error结果)
|
||||
func (r *Request) WebSocket() (*WebSocket, error) {
|
||||
if conn, err := wsUpgrader.Upgrade(r.Response.ResponseWriter.ResponseWriter, &r.Request, nil); err == nil {
|
||||
if conn, err := wsUpgrader.Upgrade(r.Response.ResponseWriter.ResponseWriter, r.Request, nil); err == nil {
|
||||
return &WebSocket {
|
||||
conn,
|
||||
}, nil
|
||||
|
||||
@ -141,6 +141,9 @@ func (c *Cookie) Remove(key, domain, path string) {
|
||||
|
||||
// 输出到客户端
|
||||
func (c *Cookie) Output() {
|
||||
if len(c.data) == 0 {
|
||||
return
|
||||
}
|
||||
for k, v := range c.data {
|
||||
// 只有 expire != 0 的才是服务端在本次请求中设置的cookie
|
||||
if v.expire == 0 {
|
||||
|
||||
@ -9,6 +9,7 @@
|
||||
package gstr_test
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@ -31,4 +32,17 @@ func Benchmark_BytesToString(b *testing.B) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func Benchmark_Strings_ToUpper(b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
strings.ToUpper(str)
|
||||
}
|
||||
}
|
||||
|
||||
func Benchmark_Strings_ToLower(b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
strings.ToLower(str)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user