HTTP Header:实现请求方法、域名、状态码等限制,实现内容替换功能

This commit is contained in:
刘祥超
2021-12-14 21:27:24 +08:00
parent 2e11c99b7a
commit a4a6e95099
2 changed files with 90 additions and 57 deletions

View File

@@ -6,6 +6,7 @@ import (
teaconst "github.com/TeaOSLab/EdgeNode/internal/const"
"github.com/TeaOSLab/EdgeNode/internal/utils"
"io"
"net/http"
"strconv"
"strings"
"sync/atomic"
@@ -129,6 +130,15 @@ func httpRequestGenBoundary() string {
return fmt.Sprintf("%x", buf[:])
}
// 判断状态是否为跳转
func httpStatusIsRedirect(statusCode int) bool {
return statusCode == http.StatusPermanentRedirect ||
statusCode == http.StatusTemporaryRedirect ||
statusCode == http.StatusMovedPermanently ||
statusCode == http.StatusSeeOther ||
statusCode == http.StatusFound
}
// 生成请求ID
var httpRequestTimestamp int64
var httpRequestId int32 = 1_000_000