Skip to content

request help: How to get pkgHTTP.Request in ResponseFilter? #153

@zxyao145

Description

@zxyao145

Issue description

I am trying to get pkgHTTP.Request in ResponseFilter method. I have modified the HTTPRespCall method in apisix-go-plugin-runner/internal/plugin/plugin.go as follows:

func HTTPRespCall(buf []byte, conn net.Conn) (*flatbuffers.Builder, error) {
+	req := inHTTP.CreateRequest(buf)
+	req.BindConn(conn)
+	defer inHTTP.ReuseRequest(req)

	resp := inHTTP.CreateResponse(buf)
	resp.BindConn(conn)
	defer inHTTP.ReuseResponse(resp)

	token := resp.ConfToken()
	conf, err := GetRuleConf(token)
	if err != nil {
		return nil, err
	}

+	err = ResponsePhase.filter(conf, resp, req)
       
       // ....
}

But I found that all the properties I received was empty. How should I handle it?

request: &{r:0xc0003ea860 conn:0xc0000122d8 extraInfoHeader:[] path:[] hdr:0xc0000122e8 rawHdr:map[] args:map[] rawArgs:map[] vars:map[] body:[] ctx:0xc00049d5c0 cancel:0x531ae0 respHdr:map[]}%!(EXTRA http.Header=map[])

If this modification is completed, I am willing to submit a PR.

Environment

  • APISIX Go Plugin Runner's version: latest
  • APISIX version: 3.6.0
  • Go version: 1.19.4
  • OS (cmd: uname -a): debian

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions