Kaynağa Gözat

wip:代码整理

wangkaiyue 2 yıl önce
ebeveyn
işleme
606767f4d7

+ 8 - 6
core/proxy/broker/outServer/SussBi.go

@@ -74,12 +74,14 @@ func (s *sussBi) Filter(r *ghttp.Request) error {
 		if err != nil {
 			return err
 		}
-		finalBytes := bytes.ReplaceAll(bodyBytes, []byte(`"jyUserId"`), []byte(fmt.Sprintf(`"%d"`, ctx.Sess.NewUid)))
-		r.ContentLength = gconv.Int64(len(finalBytes))
-		r.Request.Header.Set("Content-Length", fmt.Sprintf("%d", len(finalBytes)))
-		//fmt.Printf("before len:%d value:%s\nafter: len:%d value:%s\n", len(bodyBytes), string(bodyBytes), len(finalBytes), string(finalBytes))
-		//fmt.Printf("header %+v\n", r.Request.Header)
-		r.Request.Body = ioutil.NopCloser(bytes.NewReader(finalBytes))
+		if len(bodyBytes) > 0 {
+			finalBytes := bytes.ReplaceAll(bodyBytes, []byte(`"jyUserId"`), []byte(fmt.Sprintf(`"%d"`, ctx.Sess.NewUid)))
+			r.ContentLength = gconv.Int64(len(finalBytes))
+			r.Request.Header.Set("Content-Length", fmt.Sprintf("%d", len(finalBytes)))
+			//fmt.Printf("before len:%d value:%s\nafter: len:%d value:%s\n", len(bodyBytes), string(bodyBytes), len(finalBytes), string(finalBytes))
+			//fmt.Printf("header %+v\n", r.Request.Header)
+			r.Request.Body = ioutil.NopCloser(bytes.NewReader(finalBytes))
+		}
 	}
 	return nil
 }

+ 0 - 2
core/proxy/middleware/filterFuncs.go

@@ -22,9 +22,7 @@ func filterBefore(r *ghttp.Request) error {
 	rule := ctx.RouterRule
 
 	if rule.SessCheck.NeedCheck() {
-
 		uCheck, eCheck := rule.SessCheck.CheckUserSession(), rule.SessCheck.CheckEntSession()
-
 		if uCheck && ctx.Sess.UserId == "" {
 			return NewErrorWithCode(GLOBAL_ERR_NOTLOGIN)
 		}