size_t data_size = raw_size + extra_size;
size_t chunk_size = OSRF_MSG_CHUNK_SIZE;
+ /* Here we calculate the chunk size in bytes, which is safe because we only
+ * publish 7-bit ASCII. For any 2+ byte UTF-8, we use the JSON \u-escaping
+ * mechanism. This makes transfers larger, but is simpler to deal with as
+ * we needn't worry about splitting the string in the middle of a multi-byte
+ * character.
+ */
if (data_size > chunk_size) // calculate an escape-scaled chunk size
chunk_size = ((double)raw_size / (double)data_size) * (double)chunk_size;
size_t data_size = raw_size + extra_size;
size_t chunk_size = ctx->method->max_chunk_size;
+ /* Here we calculate the chunk size in bytes, which is safe because we only
+ * publish 7-bit ASCII. For any 2+ byte UTF-8, we use the JSON \u-escaping
+ * mechanism. This makes transfers larger, but is simpler to deal with as
+ * we needn't worry about splitting the string in the middle of a multi-byte
+ * character.
+ */
if (data_size > chunk_size) // calculate an escape-scaled chunk size
chunk_size = ((double)raw_size / (double)data_size) * (double)chunk_size;
}
if ($raw_length > $chunk_size) { # send partials ("chunking")
- for (my $i = 0; $i < length($str); $i += $chunk_size) {
+ for (my $i = 0; $i < $raw_length; $i += $chunk_size) {
$response = new OpenSRF::DomainObject::oilsResult::Partial;
$response->content( substr($str, $i, $chunk_size) );
$self->session->send($type, $response, $self->threadTrace);