mirror of
https://github.com/ProxymanApp/Proxyman.git
synced 2026-04-28 09:35:55 +03:00
[GH-ISSUE #1012] Scripting changes order of Post Form Body #1008
Labels
No labels
Discussion
Feature request
In Progress...
Plugins
Waiting response
Windows
Windows
bug
duplicate
enhancement
feature
good first issue
iOS
macOS 10.11
question
wontfix
✅ Done
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/Proxyman#1008
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Brontojoris on GitHub (Oct 5, 2021).
Original GitHub issue: https://github.com/ProxymanApp/Proxyman/issues/1012
Originally assigned to: @NghiaTranUIT on GitHub.
Proxyman version?
2.33.0 (23300)
macOS Version?
10.15.7 (19H1419)
Steps to reproduce
Expected behaviour
The order of key/value pairs displayed in the Request > Form view should match the order that the key values were originally sent in.
Screenshots (optional)
Scripting On; Body Key/Value pairs out of order
Scripting Off; Body Key/Value pairs in order
Compose request
Basic Request Script
@NghiaTranUIT commented on GitHub (Oct 5, 2021):
Hey @Brontojoris, Thanks for your ticket.
Technically, when constructing the FormParam/Header from the Scripting (JSObject in JavascriptCore) to Dictionary (Swift), Dictionary (Swift) doesn't remain the key-order. As a result, the key-value order is to mess up as you describe.
I tried to solve it by using an Array (remain key-order), but it's difficult to manipulate (add/remove) the array than doing on the JSObject
Current approach (use Dictionary)
If use Array
For that reason, I choose to use JSObject but the trade-off is the key order.
Just wondering: Does the key-order of Encoded Param affect the response? 🤔
If yes, I might find alternative solution to fix it.
@Brontojoris commented on GitHub (Oct 5, 2021):
Hi @NghiaTranUIT ,
Thanks for the quick reply. My use case is debugging Adobe Analytics beacons from iOS/Android mobile apps. Adobe send the data in a quirky format which means I am using the Request Form view a lot, and the order of the key/values is quite important. Loosely translated to JSON, their format looks a bit like:
Except in the raw body, it looks more like:
&c.&a.&key1=value%201&key2=value%202&.a&appName.&dim.&key3=value%203&key4=value%204&.dim&.appName&key5=value%205&key6=value%206&etc=etc&.c<- The dots before and after the keys represent the nesting of the structure.As a result, preserving the ordering of keys is quite important to me.
I'm using the Scripting tool to grab some of these values so I can display them in custom columns of the request list.
I would be happy for a solution where I can using the Scripting tool to clone a copy of the request object, and then manipulate that, in the hope that it doesn't mess up the key order, and I tried different things like
Object.freeze, andJSON.parse(JSON.stringify(request). But right now, it seems that even having Scripting on, will mess it up.I would even consider making a custom preview panel, but am waiting for Plugins functionality to be released.
@NghiaTranUIT commented on GitHub (Oct 5, 2021):
Thanks for your insight @Brontojoris 👍
The reason why
JSON.parse(JSON.stringify(request)orObject.freezedoesn't work is because Proxyman will parse JSObject to Dictionary (swift) after you callingreturn request;.I have an idea to fix it. Let me try and send you a beta build soon 👍
@NghiaTranUIT commented on GitHub (Oct 6, 2021):
Hey @Brontojoris, if you don't mind, please try this beta build: https://proxyman.s3.us-east-2.amazonaws.com/beta/Proxyman_2.33.0_Try_to_fix_param_order.dmg
I did a little trick when passing Swift Object to JavascriptCore, which keep the order of Headers, Query and Form Body 👍
Please let me know if it works.
@Brontojoris commented on GitHub (Oct 6, 2021):
Hi @NghiaTranUIT ,
I tested the beta, and it's working great on both my test case, and also on the Adobe requests.
Thank you so much for the speedy turnaround! :)
@NghiaTranUIT commented on GitHub (Oct 6, 2021):
awesome 👍 I will test it carefully then shipping it in the next release 😄
@NghiaTranUIT commented on GitHub (Oct 6, 2021):
I have an updated build: https://proxyman.s3.us-east-2.amazonaws.com/beta/Proxyman_2.33.0_Keep_Key-Order_v2.dmg
It fixes some issues if your request has multiple Header/Query/FormParam, which have the same key 👍
Thank you in advance 🙌
@Brontojoris commented on GitHub (Oct 13, 2021):
Apologies for the delayed reply. I tested version 2.33.0_Keep_Key-Order_v2 of the app, and can confirm everything is still working well for my use case.