Reputation: 61
I'm trying to send HTTP request with binary content using JMeter. In the documentation I found that I can send file with binary content. I think this is not a good solution for my need, since every request has its own binary content.
Here is an example of a client I wrote in Perl that demonstrates what I tried to accomplish:
$date_time = sprintf "%08X", time();
$BODY_TEMPLATE = "00${date_time}0015";
$body_len = (length (sprintf($BODY_TEMPLATE,0,0))) / 2;
# Here I set $TARGET & $HOST
$MSG_HEADER = "POST \/unil?URL=${TARGET} HTTP\/1.1\r\nHost: ${HOST}\r\ncontent-type:application/binary\r\ncontent-length: ${body_len}\r\n\r\n";
$body = pack ("H*", $BODY_TEMPLATE);
$message_to_send = $MSG_HEADER . $body;
# at this point I sent the entire message over a TCP socket I previously opened.
Any Ideas? Thanks, Yuval
Upvotes: 4
Views: 6554
Reputation: 168002
It's possible using JMeter. I would recommend using
vars.put("mybody",generatedbodystring);
. In your HTTP Sampler you can refer mybody
variable as either ${mybody}
or ${__V(mybody)}
HTTP Header Manager and BeanShell Pre Processor must be children of your HTTP Request.
You can use Debug Sampler and View Results Tree Listener to inspect request/response details and data being sent.
Hope this helps.
Upvotes: 6