Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix. The request header and the response header are different #157

Merged
merged 6 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions internal/http/header.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"net/http"

"github.com/api7/ext-plugin-proto/go/A6"
hrc "github.com/api7/ext-plugin-proto/go/A6/HTTPReqCall"
flatbuffers "github.com/google/flatbuffers/go"
)

Expand Down Expand Up @@ -83,7 +82,7 @@ func (h *Header) View() http.Header {
return h.hdr
}

func (h *Header) Build(builder *flatbuffers.Builder) flatbuffers.UOffsetT {
func HeaderBuild(h *Header, builder *flatbuffers.Builder) []flatbuffers.UOffsetT {
var hdrs []flatbuffers.UOffsetT

// deleted
Expand All @@ -108,12 +107,5 @@ func (h *Header) Build(builder *flatbuffers.Builder) flatbuffers.UOffsetT {
}
}

size := len(hdrs)
hrc.RewriteStartHeadersVector(builder, size)
for i := size - 1; i >= 0; i-- {
te := hdrs[i]
builder.PrependUOffsetT(te)
}

return builder.EndVector(size)
return hdrs
}
11 changes: 10 additions & 1 deletion internal/http/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,16 @@ func (r *Request) FetchChanges(id uint32, builder *flatbuffers.Builder) bool {

var hdrVec, respHdrVec flatbuffers.UOffsetT
if r.hdr != nil {
hdrVec = r.hdr.Build(builder)
hdrs := HeaderBuild(r.hdr, builder)

size := len(hdrs)
hrc.RewriteStartHeadersVector(builder, size)
for i := size - 1; i >= 0; i-- {
te := hdrs[i]
builder.PrependUOffsetT(te)
}

hdrVec = builder.EndVector(size)
}

if r.respHdr != nil {
Expand Down
11 changes: 10 additions & 1 deletion internal/http/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,16 @@ func (r *Response) FetchChanges(builder *flatbuffers.Builder) bool {

var hdrVec flatbuffers.UOffsetT
if r.hdr != nil {
hdrVec = r.hdr.Build(builder)
hdrs := HeaderBuild(r.hdr, builder)

size := len(hdrs)
hrc.RespStartHeadersVector(builder, size)
for i := size - 1; i >= 0; i-- {
te := hdrs[i]
builder.PrependUOffsetT(te)
}

hdrVec = builder.EndVector(size)
}

var bodyVec flatbuffers.UOffsetT
Expand Down
Loading