Page 1 of 1

ES3Cloud.AddPostField() expected behaviour?

Posted: Thu Feb 23, 2023 2:56 pm
by Krakentanz
Hey, just a quick question. Is an Instance of ES3Cloud expected to be re-used or set up fresh every time we use it?

I sent some additional Data to the php script via .AddPostField and was debugging on the apache side when i noticed the same data being sent over and over again on subsequent calls (even when calling cloud.AddPostField("sameKey","freshData") before transmitting. Upon inspection i found that there were multiple formData entries (same key, different values) piling up in the ES3Cloud instance. The php-script would always just retreive the first one of these, which would always be the first one ever added.

Is this expected behaviour? Would it make sense to add some SetPostField() method to ES3Cloud to overwrite the data? Or make overwriting the default behaviour? Or am i guilty of misconduct and should just create a fresh Instance of ES3Cloud before every call to the server? (Which is my current Solution, but i wanted to ask how it was intended to be used to avoid nasty overhead or stuff like that)

Thx as always for your support and replies! cheers

Re: ES3Cloud.AddPostField() expected behaviour?

Posted: Thu Feb 23, 2023 3:56 pm
by Joel
Hi there,

This is expected behaviour because it's often necessary to have multiple fields with the same name. For example, the server can access this as an array:

Code: Select all

es3Cloud.AddPOSTField ("brands[]", "CocaCola");
es3Cloud.AddPOSTField ("brands[]", "McDonalds");

Code: Select all

<?php
$brands = $_POST['brands'];
foreach ($brands as $brand) {
  echo $brand; // Outputs CocaColaMcDonalds
}
?>
In this case if you want different POST data to be sent you would create a new ES3Cloud object as you are currently doing :)

All the best,
Joel