Closed Bug 1353535 Opened 3 years ago Closed 3 years ago

"Copy as cURL" can't copy POST without post data

Categories

(DevTools :: Netmonitor, defect, P1)

55 Branch
defect

Tracking

(firefox55 verified)

VERIFIED FIXED
Firefox 55
Iteration:
55.3 - Apr 17
Tracking Status
firefox55 --- verified

People

(Reporter: sy.fen0, Assigned: sy.fen0)

References

Details

(Whiteboard: [netmonitor-reserve])

Attachments

(2 files, 1 obsolete file)

I have added bugfix for https://bugzilla.mozilla.org/show_bug.cgi?id=1031956. Testing this functionality I have found a TypeError when trying to copy a POST curl request with empty json data (ie: post with querystring only params).

STR:

- Make a call to any POST url using querystring params and without send any json data
- Go to Developer Tool > Network Inspector > Copy request as curl

OBS:

TypeError: postDataText is null  curl.js:206:9

EXP:

Get correct curl string on clipboard.


Seems like the problem is a String.split inside writePostDataTextParams function on curl.js file.

> let lines = postDataText.split("\r\n");

A simple fix is to add a default value for postDataText variable using:

>  postDataText = data.postDataText || "";

or we can check for null values on writePostDataTextParams function:

>  writePostDataTextParams: function (postDataText) {
>    if (!postDataText) {
>      return "";
>    }
>    let lines = postDataText.split("\r\n");
>    return lines[lines.length - 1];
>  },

any thoughts?
Attached patch bug1353535.patchSplinter Review
It's a possible implementation with tests.
Attachment #8854596 - Flags: review?(gasolin)
Assignee: nobody → sy.fen0
Status: NEW → ASSIGNED
Depends on: 1031956
Priority: -- → P1
Whiteboard: [netmonitor]
Comment on attachment 8854596 [details] [diff] [review]
bug1353535.patch

looks good to me, thanks!
Attachment #8854596 - Flags: review?(gasolin) → review+
Flags: qe-verify?
Priority: P1 → P3
Whiteboard: [netmonitor] → [netmonitor-reserve]
Flags: qe-verify? → qe-verify+
Keywords: checkin-needed
QA Contact: ciprian.georgiu
This doesn't have sufficient reviews set in MozReview for autoland to push it.
Keywords: checkin-needed
Attachment #8854715 - Attachment is obsolete: true
Keywords: checkin-needed
Pushed by ryanvm@gmail.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/6516ba9d8750
Fix "copy as curl" POST request without json data. r=gasolin
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/6516ba9d8750
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 55
Iteration: --- → 55.3 - Apr 17
Priority: P3 → P1
Hi Stefan,

I couldn't reproduce the above issue following the STR from comment 0, using an affected build.

> - Make a call to any POST url using querystring params and without send any
> json data

I don't fully understand how to do this, can you please provide me some additional info for the above step? Or there is a web page or a test case where I can test this more easily?

Thanks!
Flags: needinfo?(sy.fen0)
Hi Ciprian,

I think you need to test on version with this bugfix: https://hg.mozilla.org/mozilla-central/rev/a49b8b413df8 (it says milestone: 55.0a1)

I can reproduce this way:

STR:
- Open google.com
- Open developer tools -> Network panel
- search for anything
- after search, it'll receive a lot of GET requests and a POST
- click on this POST request, check on "Params" tab that it's only Query String params.
- Try to copy as curl this request

OBS:
Nothing is copied to clipboard

EXP:
Copy curl command for selected POST request.
Flags: needinfo?(sy.fen0)
I tested this issue on Windows 10 x64, Ubuntu 16.04 x64 and Mac OS X 101.10 with FF Nightly 55.0a1(2017-05-16) and I can confirm the fix. Please note that now if you use the right click on "POST" you will have the Copy that has multiple options.
Status: RESOLVED → VERIFIED
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.