mirror of
https://github.com/haiwen/seafile-server.git
synced 2025-09-12 21:35:30 +00:00
Add check Authorization header (#686)
Co-authored-by: 杨赫然 <heran.yang@seafile.com>
This commit is contained in:
@@ -5,10 +5,20 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var HttpReqContext, HttpReqCancel = context.WithCancel(context.Background())
|
||||
|
||||
func GetAuthorizationToken(h http.Header) string {
|
||||
auth := h.Get("Authorization")
|
||||
splitResult := strings.Split(auth, " ")
|
||||
if len(splitResult) > 1 {
|
||||
return splitResult[1]
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func HttpCommon(method, url string, header map[string][]string, reader io.Reader) (int, []byte, error) {
|
||||
req, err := http.NewRequestWithContext(HttpReqContext, method, url, reader)
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user