Sending chunked requests using Tsung

98 Views Asked by At

Does anybody know how to send POST requests with 'Transfer-Encoding' set to 'chunked' in Tsung? Do I just set the header in my request?

If so, will Tsung automatically chunk the requests? Is the chunk size configurable?

Also is there some method to disable the "Content-Length" header? My application expects only one of Content-Length or Transfer-Encoding, not both.

EDIT:

Sorry, I should have provided some sample code. Here is the Tsung snippet I used:

    <request subst="true">
      <http url="/blah/blah" method="POST" contents="{ "source_ip": "%%_requestip%%", "source_port": "%%_requestport%%", "method": "%%_method%%", "url":"%%_myurl%%", "http_version":"1.1","user_info":[{"username":"%%_myusername%%","client_id": "%%_myclientid%%"}],"headers":[{"host": "%%_apiid%%"},{"Authorization":"Bearer %%_mytoken%%"},{"x-api-key":"%%_myapikey%%"},%%_myheaderid%%]}">
             <http_header name="Head123" value="approxyhttpjkjdalsjdjasldjasldjlasjldjasdkjasljdlasjd"/>
             <http_header name="Transfer-Encoding" value="chunked"/>
             <http_header name="X-CorrelationID" value="Id-%%_requestid%%" />
             <http_header name="Content-Type" value="application/text"/>
      </http>
      </request>

As shown above, I am setting a 'Transfer-Encoding' header in my request. I have two requirements.

  1. How do I tell Tsung to send chunked packets? Is it by setting the 'Transfer-Encoding: chunked' header?
  2. How do I tell Tsung to NOT send a 'Content-Length' header in a POST request? My application cannot handle both Transfer-Encoding and Content-Length, it needs one or the other.
1

There are 1 best solutions below

4
hc_dev On

You can just override the header, see Doc's Changelog:

12.2.2. Changed

[TSUN-307] - Allow all HTTP headers to be overridden by

Read the Doc's, 6.2.2 HTTP:

New in 1.2.2: You can add any HTTP header now, as in:

    <request> <http url="/bla" method="POST" contents="bla=blu&amp;name=glop"> <www_authenticate userid="Aladdin" passwd="open sesame"/> <http_header name="Cache-Control" value="no-cache"/> <http_header name="Referer" value="http://www.w3.org/"/> </http> </request>