What does the random string after a WebKitFormBoundary do \ mean?

Hampo picture Hampo · Feb 10, 2014 · Viewed 54.6k times · Source

I'm trying to use a BI tool to automate a process which extracts data from our DB system, and then upload it to a web site via HTTP POST.

The BI Tool I'm using allows me to build the Request up as a text object which it will then send to the web resource.

To get this working I use Fiddler to capture the web request that Chrome sent when I filled in the form manually.

The request contains the following...

------WebKitFormBoundarycwwJjby5xTdrlr48
Content-Disposition: form-data; name="upload"; filename="data.csv"
Content-Type: application/vnd.ms-excel

CSV HEADER DATA 
CSV ROW DATA

------WebKitFormBoundarycwwJjby5xTdrlr48
Content-Disposition: form-data; name="returnErrorCsv"


------WebKitFormBoundarycwwJjby5xTdrlr48
Content-Disposition: form-data; name="returnUrl"


------WebKitFormBoundarycwwJjby5xTdrlr48
Content-Disposition: form-data; name="entityPropertiesToReturn"


------WebKitFormBoundarycwwJjby5xTdrlr48

I then got the BI Tool to mimic the request above and substitute in the data had extracted from the DB (where the CSV HEADER DATA and CSV ROW DATA Data would go - this data is confidential so I've had to remove it).

This is all working ok but my question is what does the string after WebKitFormBoundary mean? I.E cwwJjby5xTdrlr48

It is just a random string to identify one request from another? Or does it have another purpose?

At the moment I'm re-using cwwJjby5xTdrlr48 in all of my requests and it seems to be working ok but I thought it might be worth asking if I should construct my own string instead.

Answer

arkascha picture arkascha · Feb 20, 2014

That's just the typical way of how a so called "boundary" between different parts of a mime structure is defined. The receiving side can tell the different parts apart by this. Same logic is used in different things, email messages too for example.

That "random" string is indeed random, all boundary markers using an identical string are "grouped", so working on the same level. Mime part structures can stacked in a hierarchical manner. In such case different random strings are used in different levels to tell them apart. This is for example how citing an email as attachment to a new email. If the cited email contains multiple mime parts, their boundaries must be different to those of the new email, otherwise confusion would arise between the levels.

Actually it is not the "random part" of that boundary that counts. The whole string is matched. It is simply a convention that each software uses a unique prefix string for such boundaries for transparency reasons. But in general the only requirement is that the chosen string must be unique throughout all contained data. Unique obviously except for the corresponding boundaries which must use exactly the same string.