zxyao145 opened a new issue, #154:
URL: https://github.com/apache/apisix-go-plugin-runner/issues/154
### Issue description
I am trying to rewrite the request body and response body , and the
`RequestFilter` method code is roughly as follows:
```go
origBody := []byte("{\"keyword\": \"xxxxx\"}")
log.Infof("request get Content-Length 1: %s",
r.Header().Get("Content-Length"))
r.SetBody(origBody)
log.Infof("request get Content-Length 2: %s",
r.Header().Get("Content-Length"))
r.Header().Set("Content-Length", strconv.Itoa(len(origBody)))
log.Infof("request get Content-Length 3: %s",
r.Header().Get("Content-Length"))
```
and the log as follows:
```
request get Content-Length 1: 158
request get Content-Length 2: 158
request get Content-Length 3: 20
```
If I don't manually set the Content-Length, I will find that
`ResponseFilter` method of the same plugin cannot be triggered and a timeout
exception will occur.
```
Traceback (most recent call last):
File
"C:\Users\xxx\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\connectionpool.py",
line 467, in _make_request
six.raise_from(e, None)
File "<string>", line 3, in raise_from
File
"C:\Users\xxx\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\connectionpool.py",
line 462, in _make_request
httplib_response = conn.getresponse()
File
"C:\Users\xxx\AppData\Local\Programs\Python\Python38\lib\http\client.py", line
1344, in getresponse
response.begin()
File
"C:\Users\xxx\AppData\Local\Programs\Python\Python38\lib\http\client.py", line
307, in begin
version, status, reason = self._read_status()
File
"C:\Users\xxx\AppData\Local\Programs\Python\Python38\lib\http\client.py", line
268, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "C:\Users\xxx\AppData\Local\Programs\Python\Python38\lib\socket.py",
line 669, in readinto
return self._sock.recv_into(b)
socket.timeout: timed out
````
If this is by design, please update the documentation and the demo.
### Environment
* APISIX Go Plugin Runner's version:
github.com/apache/apisix-go-plugin-runner
v0.5.1-0.20231128010119-a265bcd63ca1
* APISIX version:
3.6.0
* Go version:
1.19
* OS (cmd: `uname -a`):
debian:bullseye-slim
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]