mirror of
https://github.com/labstack/echo.git
synced 2025-01-24 03:16:14 +02:00
parent
28ec39daaa
commit
f53eae10b3
@ -25,8 +25,8 @@ type (
|
||||
|
||||
// Request defines the interface for HTTP request.
|
||||
Request interface {
|
||||
// TLS returns true if HTTP connection is TLS otherwise false.
|
||||
TLS() bool
|
||||
// IsTLS returns true if HTTP connection is TLS otherwise false.
|
||||
IsTLS() bool
|
||||
|
||||
// Scheme returns the HTTP protocol scheme, `http` or `https`.
|
||||
Scheme() string
|
||||
@ -48,6 +48,9 @@ type (
|
||||
// ProtoMajor() int
|
||||
// ProtoMinor() int
|
||||
|
||||
// ContentLength returns the size of request's body.
|
||||
ContentLength() int
|
||||
|
||||
// UserAgent returns the client's `User-Agent`.
|
||||
UserAgent() string
|
||||
|
||||
|
@ -22,8 +22,8 @@ type (
|
||||
}
|
||||
)
|
||||
|
||||
// TLS implements `engine.Request#TLS` function.
|
||||
func (r *Request) TLS() bool {
|
||||
// IsTLS implements `engine.Request#TLS` function.
|
||||
func (r *Request) IsTLS() bool {
|
||||
return r.IsTLS()
|
||||
}
|
||||
|
||||
@ -47,6 +47,11 @@ func (r *Request) Header() engine.Header {
|
||||
return r.header
|
||||
}
|
||||
|
||||
// ContentLength implements `engine.Request#ContentLength` function.
|
||||
func (r *Request) ContentLength() int {
|
||||
return r.Request.Header.ContentLength()
|
||||
}
|
||||
|
||||
// UserAgent implements `engine.Request#UserAgent` function.
|
||||
func (r *Request) UserAgent() string {
|
||||
return string(r.RequestCtx.UserAgent())
|
||||
|
@ -19,14 +19,14 @@ type (
|
||||
}
|
||||
)
|
||||
|
||||
// TLS implements `engine.Request#TLS` function.
|
||||
func (r *Request) TLS() bool {
|
||||
// IsTLS implements `engine.Request#TLS` function.
|
||||
func (r *Request) IsTLS() bool {
|
||||
return r.Request.TLS != nil
|
||||
}
|
||||
|
||||
// Scheme implements `engine.Request#Scheme` function.
|
||||
func (r *Request) Scheme() string {
|
||||
if r.TLS() {
|
||||
if r.IsTLS() {
|
||||
return "https"
|
||||
}
|
||||
return "http"
|
||||
@ -59,6 +59,11 @@ func (r *Request) Header() engine.Header {
|
||||
// return r.request.ProtoMinor()
|
||||
// }
|
||||
|
||||
// ContentLength implements `engine.Request#ContentLength` function.
|
||||
func (r *Request) ContentLength() int {
|
||||
return int(r.Request.ContentLength)
|
||||
}
|
||||
|
||||
// UserAgent implements `engine.Request#UserAgent` function.
|
||||
func (r *Request) UserAgent() string {
|
||||
return r.Request.UserAgent()
|
||||
|
@ -25,12 +25,12 @@ func NewRequest(method, url string, body io.Reader) engine.Request {
|
||||
}
|
||||
}
|
||||
|
||||
func (r *Request) TLS() bool {
|
||||
func (r *Request) IsTLS() bool {
|
||||
return r.request.TLS != nil
|
||||
}
|
||||
|
||||
func (r *Request) Scheme() string {
|
||||
if r.TLS() {
|
||||
if r.IsTLS() {
|
||||
return "https"
|
||||
}
|
||||
return "http"
|
||||
@ -60,6 +60,10 @@ func (r *Request) Header() engine.Header {
|
||||
// return r.request.ProtoMinor()
|
||||
// }
|
||||
|
||||
func (r *Request) ContentLength() int {
|
||||
return int(r.request.ContentLength)
|
||||
}
|
||||
|
||||
func (r *Request) UserAgent() string {
|
||||
return r.request.UserAgent()
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user