How to get binary data in the beforeSendResponse callback?
- Dominant language
- JavaScript
- Stars
- 7.9k
- Forks
- 1.2k
- PR merge metrics
- No merged PRs in 30d
Description
Hi. I'm looking for a way to access binary data from proxied resources upstream. Please let me know if this is possible!
#### Which platform are you running AnyProxy
Linux (Ubuntu 18)
#### The version of the AnyProxy
4.1.2
#### Your expected behavior of AnyProxy
I would like to be able to access binary data in the `beforeSendResponse` function. It seems like this is currently not possible
#### The actual behavior of AnyProxy
```
const beforeSendResponse = async (requestDetail, responseDetail) => {
console.log(responseDetail.response)
}
```
This code logs the response, which is:
```
{
statusCode: 304,
header: {
'Cache-Control': 'private, must-revalidate, max-age=0',
Vary: 'Origin',
Server: 'Microsoft-IIS/10.0,',
'X-Content-Type-Options': 'nosniff',
'X-XSS-Protection': '1; mode=block',
'X-AspNet-Version': '4.0.30319',
'X-Powered-By': 'ASP.NET',
Date: 'Fri, 17 Apr 2020 06:10:21 GMT',
Connection: 'close',
'x-anyproxy-origin-content-length': 0
},
body: ,
rawBody: []
}
```
I know that in Node.js I would do something along the lines of:
```
result = ''
res.on('data', (body) => result += body)
res.on('end', ...)
```
I understand that this is handling 'chunks' sent as a response by the upstream server? I'm not sure... I'm quite new to this.
But from what I can tell.... I simply just can't access the response body if that body is an image or other binary data.
Surely there is a way??
Contributor guide
No contributing guide indexed for this repository
Research direction
Start at the beforeSendResponse callback and inspect how responseDetail.response exposes body and rawBody in AnyProxy 4.1.2. Verify that binary data from upstream resources is available to the callback without corruption; the payload names no file or test to run.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- networking
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100