},
})
+func Test_Uri2(t *testing.T) {
+ ctx, cancel := context.WithCancel(context.Background())
+ defer cancel()
+
+ web := pweb.New(&http.Server{
+ Addr: "127.0.0.1:19001",
+ })
+ web.Handle(map[string]func(http.ResponseWriter, *http.Request){
+ `//test/`: func(w http.ResponseWriter, r *http.Request) {
+ io.Copy(w, r.Body)
+ },
+ })
+
+ defer web.Shutdown()
+
+ conf := &Config{
+ Addr: "127.0.0.1:19000",
+ Routes: []Route{
+ {
+ Path: []string{"//test/"},
+ PathAdd: true,
+ Backs: []Back{
+ {
+ Name: "1",
+ To: "://127.0.0.1:19001",
+ Weight: 1,
+ },
+ },
+ },
+ },
+ }
+
+ go conf.Run(ctx, logger)
+
+ time.Sleep(time.Second)
+
+ reqb := []byte("1234")
+ resb := make([]byte, 5)
+
+ pipe := reqf.NewRawReqRes()
+ r := reqf.New()
+ if e := r.Reqf(reqf.Rval{
+ Url: "http://127.0.0.1:19000//test/",
+ RawPipe: pipe,
+ Async: true,
+ }); e != nil {
+ t.Fatal()
+ }
+ pipe.ReqWrite(reqb)
+ pipe.ReqClose()
+ n, _ := pipe.ResRead(resb)
+ resb = resb[:n]
+ if !bytes.Equal(resb, reqb) {
+ t.Fatal(string(resb))
+ }
+}
+
func Test_Uri(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
require (
github.com/dustin/go-humanize v1.0.1
github.com/gorilla/websocket v1.5.3
- github.com/qydysky/part v0.28.20250328130819
+ github.com/qydysky/part v0.28.20250328181619
golang.org/x/net v0.37.0
)
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/qydysky/brotli v0.0.0-20240828134800-e9913a6e7ed9 h1:k451T+bpsLr+Dq9Ujo+Qtx0iomRA1XXS5ttlEojvfuQ=
github.com/qydysky/brotli v0.0.0-20240828134800-e9913a6e7ed9/go.mod h1:cI8/gy/wjy2Eb+p2IUj2ZuDnC8R5Vrx3O0VMPvMvphA=
-github.com/qydysky/part v0.28.20250328130819 h1:rgsbvxfT15lmmKUI+6pFntLhLLdDr0EBFBaIxGg+sjI=
-github.com/qydysky/part v0.28.20250328130819/go.mod h1:RHYTy8EbqCP6OioVf6BkvFcfWLNO0S220zl0DDlY84Y=
+github.com/qydysky/part v0.28.20250328181619 h1:YaFb1luuYxKoxH7il5non/ILyRL2XGAGWS6Z640QhcM=
+github.com/qydysky/part v0.28.20250328181619/go.mod h1:RHYTy8EbqCP6OioVf6BkvFcfWLNO0S220zl0DDlY84Y=
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKlUeu/erjjvaPEYiI=