mirror of
https://github.com/WJQSERVER-STUDIO/ghproxy.git
synced 2026-02-03 16:21:11 +08:00
change to c.Request.BodyStream()
This commit is contained in:
parent
2eb6a9810b
commit
809032a970
2 changed files with 11 additions and 13 deletions
|
|
@ -1,7 +1,6 @@
|
||||||
package proxy
|
package proxy
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"ghproxy/config"
|
"ghproxy/config"
|
||||||
|
|
@ -38,17 +37,17 @@ var (
|
||||||
func ChunkedProxyRequest(ctx context.Context, c *app.RequestContext, u string, cfg *config.Config, matcher string) {
|
func ChunkedProxyRequest(ctx context.Context, c *app.RequestContext, u string, cfg *config.Config, matcher string) {
|
||||||
|
|
||||||
var (
|
var (
|
||||||
method []byte
|
method []byte
|
||||||
bodyReader *bytes.Buffer
|
//bodyReader *bytes.Buffer
|
||||||
req *http.Request
|
req *http.Request
|
||||||
resp *http.Response
|
resp *http.Response
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
|
|
||||||
method = c.Request.Method()
|
method = c.Request.Method()
|
||||||
bodyReader = bytes.NewBuffer(c.Request.Body())
|
//bodyReader = bytes.NewBuffer(c.Request.Body())
|
||||||
|
|
||||||
req, err = client.NewRequest(string(method), u, bodyReader)
|
req, err = client.NewRequest(string(method), u, c.Request.BodyStream())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
HandleError(c, fmt.Sprintf("Failed to create request: %v", err))
|
HandleError(c, fmt.Sprintf("Failed to create request: %v", err))
|
||||||
return
|
return
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
package proxy
|
package proxy
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"ghproxy/config"
|
"ghproxy/config"
|
||||||
|
|
@ -31,13 +30,13 @@ func GitReq(ctx context.Context, c *app.RequestContext, u string, cfg *config.Co
|
||||||
//err error
|
//err error
|
||||||
)
|
)
|
||||||
|
|
||||||
body := c.Request.Body()
|
//body := c.Request.Body()
|
||||||
|
|
||||||
bodyReader := bytes.NewBuffer(body)
|
//bodyReader := bytes.NewBuffer(body)
|
||||||
// 创建请求
|
// 创建请求
|
||||||
|
|
||||||
if cfg.GitClone.Mode == "cache" {
|
if cfg.GitClone.Mode == "cache" {
|
||||||
req, err := gitclient.NewRequest(method, u, bodyReader)
|
req, err := gitclient.NewRequest(method, u, c.Request.BodyStream())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
HandleError(c, fmt.Sprintf("Failed to create request: %v", err))
|
HandleError(c, fmt.Sprintf("Failed to create request: %v", err))
|
||||||
return
|
return
|
||||||
|
|
@ -52,7 +51,7 @@ func GitReq(ctx context.Context, c *app.RequestContext, u string, cfg *config.Co
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
req, err := client.NewRequest(method, u, bodyReader)
|
req, err := client.NewRequest(method, u, c.Request.BodyStream())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
HandleError(c, fmt.Sprintf("Failed to create request: %v", err))
|
HandleError(c, fmt.Sprintf("Failed to create request: %v", err))
|
||||||
return
|
return
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue