Пример #1
0
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
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
func (r *Request) Method() string {
	return engine.Bytes2str(r.context.Method())
}
Пример #4
0
func (r *Request) URI() string {
	return engine.Bytes2str(r.context.RequestURI())
}
Пример #5
0
func (r *Request) Host() string {
	return engine.Bytes2str(r.context.Host())
}
Пример #6
0
func (r *Request) Scheme() string {
	return engine.Bytes2str(r.context.URI().Scheme())
}
Пример #7
0
func (r *Request) UserAgent() string {
	return engine.Bytes2str(r.context.UserAgent())
}
Пример #8
0
func (r *Request) Referer() string {
	return engine.Bytes2str(r.context.Referer())
}
Пример #9
0
func (r *Request) Cookie(key string) string {
	return engine.Bytes2str(r.context.Request.Header.Cookie(key))
}
Пример #10
0
func (u *UrlValue) Get(key string) string {
	u.init()
	return engine.Bytes2str(u.Args.Peek(key))
}
Пример #11
0
func (u *URL) RawQuery() string {
	return engine.Bytes2str(u.url.QueryString())
}
Пример #12
0
func (u *URL) QueryValue(name string) string {
	return engine.Bytes2str(u.url.QueryArgs().Peek(name))
}
Пример #13
0
func (u *URL) Path() string {
	return engine.Bytes2str(u.url.Path())
}
Пример #14
0
func (u *URL) RawPath() string {
	return engine.Bytes2str(u.url.PathOriginal())
}
Пример #15
0
func (h *ResponseHeader) Get(key string) string {
	return engine.Bytes2str(h.header.Peek(key))
}