[GH-ISSUE #759] script onResponse with base64 response data from server return not correct #753

Open
opened 2026-03-03 19:21:36 +03:00 by kerem · 10 comments
Owner

Originally created by @ixqbar on GitHub (Jan 14, 2021).
Original GitHub issue: https://github.com/ProxymanApp/Proxyman/issues/759

Originally assigned to: @NghiaTranUIT on GitHub.

Proxyman version? (Ex. Proxyman 1.4.3)

2.16.0

macOS Version? (Ex. mac 10.14)

11.0.1

Steps to reproduce

Expected behavior

Screenshots (optional)

image
image
image

Originally created by @ixqbar on GitHub (Jan 14, 2021). Original GitHub issue: https://github.com/ProxymanApp/Proxyman/issues/759 Originally assigned to: @NghiaTranUIT on GitHub. ### Proxyman version? (Ex. Proxyman 1.4.3) 2.16.0 ### macOS Version? (Ex. mac 10.14) 11.0.1 ### Steps to reproduce ### Expected behavior ### Screenshots (optional) ![image](https://user-images.githubusercontent.com/960982/104547153-cf556600-5668-11eb-8fb4-b440f0933f60.png) ![image](https://user-images.githubusercontent.com/960982/104546985-5d7d1c80-5668-11eb-81b2-0eb7321a5fee.png) ![image](https://user-images.githubusercontent.com/960982/104547008-6c63cf00-5668-11eb-81ca-981761563516.png)
Author
Owner

@NghiaTranUIT commented on GitHub (Jan 14, 2021):

Hi @jonnywang, if you disable a rule, what the value of console.log(res.data) and console.log(res.data.length) from your code?

Is it the same value (108)? 🤔

<!-- gh-comment-id:759936316 --> @NghiaTranUIT commented on GitHub (Jan 14, 2021): Hi @jonnywang, if you disable a rule, what the value of `console.log(res.data)` and `console.log(res.data.length)` from your code? Is it the same value (108)? 🤔
Author
Owner

@NghiaTranUIT commented on GitHub (Jan 14, 2021):

From the second screenshot, the value of console.log(res.data) is a binary (You can see the invalid characters).

The reason why you see the Base64 string in console.log(response.body) is because we convert the binary value to Base64 string since there is no way to pass Binary Data from Swift to the JavascriptCore. Therefore, the string might take 152 in lengths rather than 108 from the binary format.

Proxyman also converts the base64 string in the response.body to the binary format too.

So it's correct behavior 🤔

Not sure what this behavior causes to you @jonnywang ?

<!-- gh-comment-id:759938466 --> @NghiaTranUIT commented on GitHub (Jan 14, 2021): From the second screenshot, the value of `console.log(res.data)` is a binary (You can see the invalid characters). The reason why you see the Base64 string in `console.log(response.body)` is because we convert the binary value to Base64 string since there is no way to pass Binary Data from Swift to the JavascriptCore. Therefore, the string might take 152 in lengths rather than 108 from the binary format. Proxyman also converts the base64 string in the response.body to the binary format too. So it's correct behavior 🤔 Not sure what this behavior causes to you @jonnywang ?
Author
Owner

@ixqbar commented on GitHub (Jan 14, 2021):

152 is right, server response data is base64 encode data, but after using proxy the client got not collect response data length

<!-- gh-comment-id:759940132 --> @ixqbar commented on GitHub (Jan 14, 2021): 152 is right, server response data is base64 encode data, but after using proxy the client got not collect response data length
Author
Owner

@NghiaTranUIT commented on GitHub (Jan 14, 2021):

@jonnywang if you don't mind, please help me log two following scenario:

  1. Disable a rule, what the value of console.log(res.data) and console.log(res.data.length) from your code?
  2. Enable a Rule, what the value is?

It's easier for me to fix it 😄

<!-- gh-comment-id:759941674 --> @NghiaTranUIT commented on GitHub (Jan 14, 2021): @jonnywang if you don't mind, please help me log two following scenario: 1. Disable a rule, what the value of console.log(res.data) and console.log(res.data.length) from your code? 2. Enable a Rule, what the value is? It's easier for me to fix it 😄
Author
Owner

@ixqbar commented on GitHub (Jan 14, 2021):

after disable rule, client logs

image

<!-- gh-comment-id:759942235 --> @ixqbar commented on GitHub (Jan 14, 2021): after disable rule, client logs ![image](https://user-images.githubusercontent.com/960982/104550185-4130ae00-566f-11eb-9fe5-1433d090122e.png)
Author
Owner

@NghiaTranUIT commented on GitHub (Jan 14, 2021):

Thanks. Let me try to reproduce this bug on my end 👍

<!-- gh-comment-id:759942473 --> @NghiaTranUIT commented on GitHub (Jan 14, 2021): Thanks. Let me try to reproduce this bug on my end 👍
Author
Owner

@ixqbar commented on GitHub (Jan 14, 2021):

👍

<!-- gh-comment-id:759942788 --> @ixqbar commented on GitHub (Jan 14, 2021): 👍
Author
Owner

@NghiaTranUIT commented on GitHub (Jan 14, 2021):

Hey @jonnywang Let check out this beta build: https://proxyman.s3.us-east-2.amazonaws.com/beta/Proxyman_2.16.0_Fix_Base64.dmg

and please let me know if it works for you 🙌

<!-- gh-comment-id:759983181 --> @NghiaTranUIT commented on GitHub (Jan 14, 2021): Hey @jonnywang Let check out this beta build: https://proxyman.s3.us-east-2.amazonaws.com/beta/Proxyman_2.16.0_Fix_Base64.dmg and please let me know if it works for you 🙌
Author
Owner

@ixqbar commented on GitHub (Jan 14, 2021):

test ok,fixed!
👍

<!-- gh-comment-id:760052864 --> @ixqbar commented on GitHub (Jan 14, 2021): test ok,fixed! 👍
Author
Owner

@NghiaTranUIT commented on GitHub (Jan 14, 2021):

💯

<!-- gh-comment-id:760216287 --> @NghiaTranUIT commented on GitHub (Jan 14, 2021): 💯
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/Proxyman#753
No description provided.