Emulating a behavior of a browser in a continuous way

Hello,

My goal is to simulate the way our client-server flow.
The client has to send X (X is usually > 12) REST calls to server. As the browser defaults to 6 persistent connections to server and the 7th request is waiting for one of the first six to finish - I’d like to accomplish the same in my scenario.

feed(inventoryFilterFeeder)
        .exec(ApiRequests.getData(
          "Get All", caseCls.ALL.bodyFileName, caseCls.ALL.sessionName)
          .resources(
            ApiRequests.getData(
              "Get Source", caseCls.SOURCE.bodyFileName, caseCls.SOURCE.sessionName),
            ApiRequests.getData(
              "Get Attribute", caseCls.ATTRIBUTE.bodyFileName, caseCls.ATTRIBUTE.sessionName),
            ApiRequests.getData(
              "Get Dup", caseCls.DUP.bodyFileName, caseCls.DUPsessionName),
            ApiRequests.getData(
              "Get Access", caseCls.ACCESS.bodyFileName, caseCls.ACCESS.sessionName),
            ApiRequests.getData(
              "Get Object Status", caseCls.OBJ_STATUS.bodyFileName, caseCls.OBJ_STATUS.sessionName)
          ))
      .exec(ApiRequests.getData(
        "Get Raw", caseCls.RAW.bodyFileName, caseCls.RAW.sessionName)
        .resources(
          ApiRequests.getData(
            "Get Pol", caseCls.POL.bodyFileName, caseCls.POL.sessionName),
          ApiRequests.getData(
            "Get File Type", caseCls.FILE_TYPE.bodyFileName, caseCls.FILE_TYPE.sessionName),
          ApiRequests.getData(
            "Get Cloud Type", caseCls.CLOUD_TYPE.bodyFileName, caseCls.CLOUD_TYPE.sessionName),
          ApiRequests.getData(
            "Get Data Format", caseCls.DATA_FORMAT.bodyFileName, caseCls.DATA_FORMAT.sessionName),
          ApiRequests.getData(
            "Get Status", caseCls.STATUS.bodyFileName, caseCls.STATUS.sessionName)
        ))
      .exec(ApiRequests.getData(
        "Get Tags", caseCls.TAGS.bodyFileName, caseCls.TAGS.sessionName)
        .resources(
          ApiRequests.getData(
            "Get Owner", caseCls.OWNER.bodyFileName, caseCls.OWNER.sessionName),
          ApiRequests.getData(
            "Get Source Type", caseCls.SOURCE_TYPE.bodyFileName, caseCls.SOURCE_TYPE.sessionName),
          ApiRequests.getData(
            "Get Filter", caseCls.FILTER.bodyFileName, caseCls.SFILTER.sessionName),
          ApiRequests.getData(
            "Get Details Type", caseCls.ADETAILS_TYPE.bodyFileName, caseCls.ADETAILS_TYPE.sessionName)
        ))

maxConnectionsPerHost is set to the default 6

I think that this scenario causes that the first six requests are sent and the next one is sent only after the fir six are done.
Am I wrong?
How is it possible to rewrite it so each subsequent request will be sent as soon as a connection is freed?

Wrong. Assuming all requests target the same host, the 7th one is sent as soon as the response of the one of the first 6 requests is received. Just like a browser.

Note: This is the HTTP/1.1 behavior. If you enable HTTP/2, you’ll open concurrent HTTP/2 streams.

Got it, thank you.

And a slightly different question: in case maxConnectionsPerHost is less than amount of requests in .resources, I see that only maxConnectionsPerHost requests are executed and the rest is not (the scenario stops).
Why is that?

I see that only maxConnectionsPerHost requests are executed and the rest is not (the scenario stops).

Wrong. A first batch of maxConnectionsPerHost requests is triggered and the other ones will follow when some of the first ones complete and hence connections are available.

If that’s not not the behavior you’re observing, please provide a reproducer.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.