@@ -537,11 +537,11 @@ func TestHTTP2Thrift_Nesting(t *testing.T) {
537537 req := getSampleHttpRequest (stru2 , nestingJSON )
538538 ctx := context .WithValue (context .Background (), conv .CtxKeyHTTPRequest , req )
539539 cv := j2t .NewBinaryConv (conv.Options {
540- WriteDefaultField : true ,
541- EnableHttpMapping : true ,
542- EnableValueMapping : true ,
540+ WriteDefaultField : true ,
541+ EnableHttpMapping : true ,
542+ EnableValueMapping : true ,
543543 TracebackRequredOrRootFields : true ,
544- ReadHttpValueFallback : true ,
544+ ReadHttpValueFallback : true ,
545545 })
546546 nj := convertI642StringNesting (nestingJSON , true )
547547 out , err := cv .Do (ctx , nesting , []byte (nj ))
@@ -561,12 +561,12 @@ func TestHTTP2Thrift_Nesting_Parallel(t *testing.T) {
561561 // fmt.Printf("%#v", nesting)
562562
563563 cv := j2t .NewBinaryConv (conv.Options {
564- WriteDefaultField : true ,
565- EnableHttpMapping : true ,
566- EnableValueMapping : true ,
564+ WriteDefaultField : true ,
565+ EnableHttpMapping : true ,
566+ EnableValueMapping : true ,
567567 TracebackRequredOrRootFields : true ,
568- ReadHttpValueFallback : true ,
569- OmitHttpMappingErrors : true ,
568+ ReadHttpValueFallback : true ,
569+ OmitHttpMappingErrors : true ,
570570 })
571571 nj := convertI642StringNesting (nestingJSON , true )
572572 println (nj )
@@ -837,62 +837,62 @@ func BenchmarkHTTP2Thrift_DynamicGo_Raw(b *testing.B) {
837837 })
838838}
839839
840- func getKitexHttpRequest (req * descriptor.HTTPRequest ) {
841- header := "你好"
842- req .Header .Set ("String" , header )
843- // exp.String_ = header
844- // h2 := "abcdefghijklmnopqrstuvwxyz"
845- // req.Header.Set("string_field", h2)
846- // exp.SimpleStruct.StringField = h2
847- // for i := range exp.ListSimple {
848- // exp.ListSimple[i].StringField = h2
849- // }
850- // for k := range exp.MapStringSimple {
851- // exp.MapStringSimple[k].StringField = h2
852- // }
853-
854- c := []int64 {- 1 , 0 , math .MaxInt64 , math .MinInt64 }
855- cookie := ""
856- for i , v := range c {
857- cookie += strconv .Itoa (int (v ))
858- if i != len (c )- 1 {
859- cookie += ","
860- }
861- }
862- req .Cookies ["list_i64" ] = cookie
863- // exp.ListI64 = c
864-
865- // param := math.MaxFloat64
866- // req.Params.Set("double", strconv.FormatFloat(param, 'f', -1, 64))
867- // exp.Double = param
868-
869- q := []int32 {- 1 , 0 , math .MaxInt32 , math .MinInt32 }
870- query := ""
871- for i , v := range q {
872- query += strconv .Itoa (int (v ))
873- if i != len (q )- 1 {
874- query += ","
875- }
876- }
877- req .Query .Set ("ListI32" , query )
878- // exp.ListI32 = q
840+ // func getKitexHttpRequest(req *descriptor.HTTPRequest) {
841+ // header := "你好"
842+ // req.Header.Set("String", header)
843+ // // exp.String_ = header
844+ // // h2 := "abcdefghijklmnopqrstuvwxyz"
845+ // // req.Header.Set("string_field", h2)
846+ // // exp.SimpleStruct.StringField = h2
847+ // // for i := range exp.ListSimple {
848+ // // exp.ListSimple[i].StringField = h2
849+ // // }
850+ // // for k := range exp.MapStringSimple {
851+ // // exp.MapStringSimple[k].StringField = h2
852+ // // }
853+
854+ // c := []int64{-1, 0, math.MaxInt64, math.MinInt64}
855+ // cookie := ""
856+ // for i, v := range c {
857+ // cookie += strconv.Itoa(int(v))
858+ // if i != len(c)-1 {
859+ // cookie += ","
860+ // }
861+ // }
862+ // req.Cookies["list_i64"] = cookie
863+ // // exp.ListI64 = c
864+
865+ // // param := math.MaxFloat64
866+ // // req.Params.Set("double", strconv.FormatFloat(param, 'f', -1, 64))
867+ // // exp.Double = param
868+
869+ // q := []int32{-1, 0, math.MaxInt32, math.MinInt32}
870+ // query := ""
871+ // for i, v := range q {
872+ // query += strconv.Itoa(int(v))
873+ // if i != len(q)-1 {
874+ // query += ","
875+ // }
876+ // }
877+ // req.Query.Set("ListI32", query)
878+ // // exp.ListI32 = q
879879
880- // exp.I32 = 0
880+ // // exp.I32 = 0
881881
882- var helper = func (sim map [string ]interface {}) {
883- sim ["I32Field" ] = int32 (sim ["I32Field" ].(int64 ))
884- sim ["ByteField" ] = int8 (sim ["ByteField" ].(int64 ))
885- }
886- for _ , v := range req .Body ["MapStringSimple" ].(map [string ]interface {}) {
887- helper (v .(map [string ]interface {}))
888- }
889- for _ , v := range req .Body ["ListSimple" ].([]interface {}) {
890- helper (v .(map [string ]interface {}))
891- }
892- helper (req .Body ["SimpleStruct" ].(map [string ]interface {}))
893- req .Body ["Byte" ] = int8 (req .Body ["Byte" ].(int64 ))
882+ // var helper = func(sim map[string]interface{}) {
883+ // sim["I32Field"] = int32(sim["I32Field"].(int64))
884+ // sim["ByteField"] = int8(sim["ByteField"].(int64))
885+ // }
886+ // for _, v := range req.Body["MapStringSimple"].(map[string]interface{}) {
887+ // helper(v.(map[string]interface{}))
888+ // }
889+ // for _, v := range req.Body["ListSimple"].([]interface{}) {
890+ // helper(v.(map[string]interface{}))
891+ // }
892+ // helper(req.Body["SimpleStruct"].(map[string]interface{}))
893+ // req.Body["Byte"] = int8(req.Body["Byte"].(int64))
894894
895- }
895+ // }
896896
897897func BenchmarkHTTP2Thrift_KitexGeneric (b * testing.B ) {
898898 p , err := generic .NewThriftFileProvider (idlPath )
@@ -904,9 +904,10 @@ func BenchmarkHTTP2Thrift_KitexGeneric(b *testing.B) {
904904
905905 b .Run ("small" , func (b * testing.B ) {
906906 codec := gthrift .NewWriteHTTPRequest (svcDsc )
907- req := & descriptor.HTTPRequest {
908- Method : "POST" ,
909- Path : "/simple" ,
907+ req := & descriptor.HTTPRequest {}
908+ req .Request , err = stdh .NewRequest ("POST" , "/simple" , nil )
909+ if err != nil {
910+ b .Fatal (err )
910911 }
911912 jc := sonic.Config {
912913 UseInt64 : true ,
0 commit comments