user1876122
user1876122

Reputation: 133

Integrity check of posted data with XmlHttpRequest?

Does an Ajax Post XmlHttpRequest perform an integrity check on the data sent to the server, so that the server may see that it wasn't damaged in transit..?

If not, how could I accomplish this type of integrity check to ensure the data wasn't damaged in transit..?

Upvotes: 1

Views: 494

Answers (1)

Ian Atkin
Ian Atkin

Reputation: 6356

Other than the usual packet corruption tests that are carried out over TCP/IP, no, there is no integrity checking taking place (under normal circumstances).

The script that listens for XmlHttpRequests is responsible for doing any kind of parity checking or data integrity. It's supposed that in a scenario where discrete parameters are being transmitted, then there will be certain tests that can be performed on that incoming data.

For example, if a field is expected to contain an integer, the sudden appearance of a alphanumeric value would work as a simple test. Tests could be performed for ranges of values, lengths of individual parameters, whether a field belongs to a set of enumerations ("cat", "dog", "horse", "cow"), etc.

Of course, in a situation where a block of text, or other variable data are expected, testing specific values gets more difficult.

Another possibility would be to calculate some parity check based on the actual concatenated data, and send that alongside with the data itself. Re-doing the calculation on the receiving end and comparing the result to the parity value would be a simple matter.

Upon any failure, a message to that effect would be sent back to the calling script.

Upvotes: 2

Related Questions