示例#1
0
文件: urlValue.go 项目: webx-top/echo
func (u *UrlValue) All() map[string][]string {
	if u.values != nil {
		return *u.values
	}
	r := url.Values{}
	u.init()
	u.Args.VisitAll(func(k, v []byte) {
		key := engine.Bytes2str(k)
		r.Add(key, engine.Bytes2str(v))
	})
	u.values = &r
	return *u.values
}
示例#2
0
文件: request.go 项目: webx-top/echo
func (r *Request) StdRequest() *http.Request {
	if r.stdRequest != nil {
		return r.stdRequest
	}
	var req http.Request
	ctx := r.context
	req.Method = r.Method()
	req.Proto = "HTTP/1.1"
	req.ProtoMajor = 1
	req.ProtoMinor = 1
	req.RequestURI = r.URI()
	req.ContentLength = r.Size()
	req.Host = r.Host()
	req.RemoteAddr = r.RemoteAddress()

	hdr := make(http.Header)
	ctx.Request.Header.VisitAll(func(k, v []byte) {
		sk := engine.Bytes2str(k)
		sv := engine.Bytes2str(v)
		switch sk {
		case "Transfer-Encoding":
			req.TransferEncoding = append(req.TransferEncoding, sv)
		default:
			hdr.Set(sk, sv)
		}
	})
	req.Header = hdr
	req.Body = r.Body()
	rURL, err := url.ParseRequestURI(req.RequestURI)
	if err != nil {
		ctx.Logger().Printf("cannot parse requestURI %q: %s", req.RequestURI, err)
		r.response.Error("Internal Server Error")
	}
	req.URL = rURL
	r.stdRequest = &req
	return r.stdRequest
}
示例#3
0
文件: request.go 项目: webx-top/echo
func (r *Request) Method() string {
	return engine.Bytes2str(r.context.Method())
}
示例#4
0
文件: request.go 项目: webx-top/echo
func (r *Request) URI() string {
	return engine.Bytes2str(r.context.RequestURI())
}
示例#5
0
文件: request.go 项目: webx-top/echo
func (r *Request) Host() string {
	return engine.Bytes2str(r.context.Host())
}
示例#6
0
文件: request.go 项目: webx-top/echo
func (r *Request) Scheme() string {
	return engine.Bytes2str(r.context.URI().Scheme())
}
示例#7
0
文件: request.go 项目: webx-top/echo
func (r *Request) UserAgent() string {
	return engine.Bytes2str(r.context.UserAgent())
}
示例#8
0
文件: request.go 项目: webx-top/echo
func (r *Request) Referer() string {
	return engine.Bytes2str(r.context.Referer())
}
示例#9
0
文件: request.go 项目: webx-top/echo
func (r *Request) Cookie(key string) string {
	return engine.Bytes2str(r.context.Request.Header.Cookie(key))
}
示例#10
0
文件: urlValue.go 项目: webx-top/echo
func (u *UrlValue) Get(key string) string {
	u.init()
	return engine.Bytes2str(u.Args.Peek(key))
}
示例#11
0
文件: url.go 项目: webx-top/echo
func (u *URL) RawQuery() string {
	return engine.Bytes2str(u.url.QueryString())
}
示例#12
0
文件: url.go 项目: webx-top/echo
func (u *URL) QueryValue(name string) string {
	return engine.Bytes2str(u.url.QueryArgs().Peek(name))
}
示例#13
0
文件: url.go 项目: webx-top/echo
func (u *URL) Path() string {
	return engine.Bytes2str(u.url.Path())
}
示例#14
0
文件: url.go 项目: webx-top/echo
func (u *URL) RawPath() string {
	return engine.Bytes2str(u.url.PathOriginal())
}
示例#15
0
文件: header.go 项目: webx-top/echo
func (h *ResponseHeader) Get(key string) string {
	return engine.Bytes2str(h.header.Peek(key))
}