Bug 60649 - HTTP(S) Test Script Recorder: wrong postdata
Summary: HTTP(S) Test Script Recorder: wrong postdata
Status: NEW
Alias: None
Product: JMeter
Classification: Unclassified
Component: HTTP (show other bugs)
Version: 3.1
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: JMeter issues mailing list
URL:
Keywords: PatchAvailable
Depends on:
Blocks:
 
Reported: 2017-01-26 14:10 UTC by Biagio
Modified: 2020-11-14 21:57 UTC (History)
2 users (show)



Attachments
Try to guess if body data is of name=value form (1.32 KB, patch)
2017-01-26 15:00 UTC, Felix Schumacher
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Biagio 2017-01-26 14:10:18 UTC
I'm using jmeter to record an internal web application, in my application are maked some httprequest by Javascript code that pass as postdata a simple key:

<POSTDATA>
KEY

If i call my web application without recording all works fine, if i call my application while jmeter is record the application don't work.
The problem is that jmeter recording module modify the post data adding the "=" character to request
<POSTDATA>
KEY=

Thanks
Comment 1 Felix Schumacher 2017-01-26 15:00:39 UTC
Created attachment 34680 [details]
Try to guess if body data is of name=value form

If no content-type is given for a post body, or it is the default one, DefaultSamplerCreater will assume it is of the form name=value. This patch looks for an equals sign in the body and if it finds none, it will assume, that the body is not of the name=value form.
Comment 2 Philippe Mouawad 2017-01-26 15:05:40 UTC
(In reply to Felix Schumacher from comment #1)
> Created attachment 34680 [details]
> Try to guess if body data is of name=value form
> 
> If no content-type is given for a post body, or it is the default one,
> DefaultSamplerCreater will assume it is of the form name=value. This patch
> looks for an equals sign in the body and if it finds none, it will assume,
> that the body is not of the name=value form.

Hi Felix.
What if content is json ?
It will contain '=' , will it work ? 
AFAIK, recorder handles correctly json no ?

@Biagio, could you provide the exact post body ?
Thanks
Comment 3 Felix Schumacher 2017-01-26 19:41:00 UTC
The patch will only work for the simplest case. It might even not work for base64 coded data.

But the problem only arises, when no or the default content-type is used. My hope is, that clients sending JSON will use the correct content-type.

Another possible solution would be to check whether the body data starts with a regex like "(?i)[a-z0-9_.-]{30}=.", assuming that keys are not too long and consists of only 'simple' characters.

But that seems even less fool- or fail-proof.
Comment 4 Pierre 2020-11-14 21:53:11 UTC
I am getting the same behavior on my tests because the content-type is not correctly set on the app i'm testing...

What do you think if the behavior of DefaultSamplerCreater is changed like this:
1. Tries to parse data and splits name and value (I assume it's the current way of working)
2. If 'name' is not null AND 'value' is null, then consider that the format is just raw data, not name=value

From a quick look, if it really was a name=value format but with an empty value, the data will still be sent to the server like received while recording, with no modifications, so it'll be fine.

Let me know your thoughts!