Programatically set POST binary content yìto HTTP sampler in Jmeter

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Programatically set POST binary content yìto HTTP sampler in Jmeter

sbos-61
Hi everybody,

I'm writing a Load test that send Time Stamping Requests to a Time Stamping Autority.

This is a standard protocol, described in rfc3161. This require a POST execution, sending a small ASN1 object, that is binary.

Now, I have written the groovy part that set up the ASN1 object, and that creates the *bytes[] array*, but I cannot copy to a
variable, because the casting to a string *modifies* the content. However I cannot find any other way to pass this content.

Given the amount of traffic I have to generate, writing to a file and then attach it is not a viable solution.

Is there any other way to work around this issue?

Thank you in advance!




--

Ing. Sergio Boso



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Programatically set POST binary content yìto HTTP sampler in Jmeter

Felix Schumacher

Am 08.02.20 um 12:47 schrieb Sergio Boso:

> Hi everybody,
>
> I'm writing a Load test that send Time Stamping Requests to a Time
> Stamping Autority.
>
> This is a standard protocol, described in rfc3161. This require a POST
> execution, sending a small ASN1 object, that is binary.
>
> Now, I have written the groovy part that set up the ASN1 object, and
> that creates the *bytes[] array*, but I cannot copy to a variable,
> because the casting to a string *modifies* the content. However I
> cannot find any other way to pass this content.

Have you tried to convert the bytes array to a string using an 8-bit
encoding like iso-8859-1?

 String request = new String(asnBytes,
java.nio.charsets.StandardCharsets.ISO_8859_1)

Another possibility would be to convert it to base64

 String b64Request = Base64.mimeEncoder.encodeToString(x)

and send that value with a content-transfer-encoding header set to "base64".

Felix

>
> Given the amount of traffic I have to generate, writing to a file and
> then attach it is not a viable solution.
>
> Is there any other way to work around this issue?
>
> Thank you in advance!
>
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Programatically set POST binary content yìto HTTP sampler in Jmeter

sbos-61
Yes it works!!

Also I had to set the "Content encoding" in the Sampler to "ISO-8859-1".
Thank you.


Sergio


Il 09/02/2020 12:50, Felix Schumacher ha scritto:

> Am 08.02.20 um 12:47 schrieb Sergio Boso:
>> Hi everybody,
>>
>> I'm writing a Load test that send Time Stamping Requests to a Time
>> Stamping Autority.
>>
>> This is a standard protocol, described in rfc3161. This require a POST
>> execution, sending a small ASN1 object, that is binary.
>>
>> Now, I have written the groovy part that set up the ASN1 object, and
>> that creates the *bytes[] array*, but I cannot copy to a variable,
>> because the casting to a string *modifies* the content. However I
>> cannot find any other way to pass this content.
> Have you tried to convert the bytes array to a string using an 8-bit
> encoding like iso-8859-1?
>
>   String request = new String(asnBytes,
> java.nio.charsets.StandardCharsets.ISO_8859_1)
>
> Another possibility would be to convert it to base64
>
>   String b64Request = Base64.mimeEncoder.encodeToString(x)
>
> and send that value with a content-transfer-encoding header set to "base64".
>
> Felix
>
>> Given the amount of traffic I have to generate, writing to a file and
>> then attach it is not a viable solution.
>>
>> Is there any other way to work around this issue?
>>
>> Thank you in advance!
>>
>>
>>
>>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>


--

Ing. Sergio Boso

Mail:
Cell:
Web:
Linkedin:
PEC:
Skype:

       

[hidden email] <mailto:[hidden email]>
+39 335 7243 445
www.bosoconsulting.it <http://www.bosoconsulting.it>
http://it.linkedin.com/in/sergioboso <http://www.linkedin.com/pub/sergio-boso/1/29b/255>
[hidden email] <mailto:[hidden email]>
sbos61




---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Programatically set POST binary content yìto HTTP sampler in Jmeter

Felix Schumacher

Am 09.02.20 um 20:23 schrieb Sergio Boso:
> Yes it works!!
>
> Also I had to set the "Content encoding" in the Sampler to "ISO-8859-1".

So I guess you took the first variant?

> Thank you.

Glad it worked.

Felix

>
>
> Sergio
>
>
> Il 09/02/2020 12:50, Felix Schumacher ha scritto:
>> Am 08.02.20 um 12:47 schrieb Sergio Boso:
>>> Hi everybody,
>>>
>>> I'm writing a Load test that send Time Stamping Requests to a Time
>>> Stamping Autority.
>>>
>>> This is a standard protocol, described in rfc3161. This require a POST
>>> execution, sending a small ASN1 object, that is binary.
>>>
>>> Now, I have written the groovy part that set up the ASN1 object, and
>>> that creates the *bytes[] array*, but I cannot copy to a variable,
>>> because the casting to a string *modifies* the content. However I
>>> cannot find any other way to pass this content.
>> Have you tried to convert the bytes array to a string using an 8-bit
>> encoding like iso-8859-1?
>>
>>   String request = new String(asnBytes,
>> java.nio.charsets.StandardCharsets.ISO_8859_1)
>>
>> Another possibility would be to convert it to base64
>>
>>   String b64Request = Base64.mimeEncoder.encodeToString(x)
>>
>> and send that value with a content-transfer-encoding header set to
>> "base64".
>>
>> Felix
>>
>>> Given the amount of traffic I have to generate, writing to a file and
>>> then attach it is not a viable solution.
>>>
>>> Is there any other way to work around this issue?
>>>
>>> Thank you in advance!
>>>
>>>
>>>
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]