return $self->{max_bundle_size};
}
+sub max_chunk_size {
+ my $self = shift;
+ my $value = shift;
+ $self->{max_chunk_size} = $value if (defined($value));
+ return $self->{max_chunk_size};
+}
+
sub recv_timeout {
my $self = shift;
my $timeout = shift;
my $msg = shift;
return unless ($self and $self->session and !$self->complete);
-
my $type = 'RESULT';
my $response;
if (ref($msg) && UNIVERSAL::isa($msg, 'OpenSRF::DomainObject::oilsResponse')) {
$response = $msg;
$type = 'STATUS' if UNIVERSAL::isa($response, 'OpenSRF::DomainObject::oilsStatus');
- } elsif ($self->max_chunk_size > 0) { # we might need to chunk
- my $str = OpenSRF::Utils::JSON->perl2JSON($msg);
- if (length($str) > $self->max_chunk_size) { # send partials ("chunking")
- for (my $i = 0; $i < length($str); $i += $self->max_chunk_size) {
- $response = new OpenSRF::DomainObject::oilsResult::Partial;
- $response->content( substr($str, $i, $self->max_chunk_size) );
- $self->session->send($type, $response, $self->threadTrace);
+
+ } else {
+
+ if ($self->max_chunk_size > 0) { # we might need to chunk
+ my $str = OpenSRF::Utils::JSON->perl2JSON($msg);
+ if (length($str) > $self->max_chunk_size) { # send partials ("chunking")
+ for (my $i = 0; $i < length($str); $i += $self->max_chunk_size) {
+ $response = new OpenSRF::DomainObject::oilsResult::Partial;
+ $response->content( substr($str, $i, $self->max_chunk_size) );
+ $self->session->send($type, $response, $self->threadTrace);
+ }
+ # This triggers reconstruction on the remote end
+ $response = new OpenSRF::DomainObject::oilsResult::PartialComplete;
+ return $self->session->send($type, $response, $self->threadTrace);
}
- # This triggers reconstruction on the remote end
- $response = new OpenSRF::DomainObject::oilsResult::PartialComplete;
- return $self->session->send($type, $response, $self->threadTrace);
- } else {
- $response = new OpenSRF::DomainObject::oilsResult;
- $response->content( $msg );
}
+
+ # message failed to exceed max chunk size OR chunking disabled
+ $response = new OpenSRF::DomainObject::oilsResult;
+ $response->content($msg);
}
if ($self->{max_bundle_count} > 0 or $self->{max_bundle_size} > 0) { # we are bundling, and we need to test the size or count
my $self = shift;
return 0 unless ref($self);
return $self->{max_chunk_size} if (defined($self->{max_chunk_size}));
- return 2 * $self->max_bundle_size;
+ return 104858; # 1/10 MB
}
sub api_name {
my $appreq = OpenSRF::AppRequest->new( $session );
$appreq->max_bundle_size( $coderef->max_bundle_size );
$appreq->max_bundle_count( $coderef->max_bundle_count );
+ $appreq->max_chunk_size( $coderef->max_chunk_size );
$log->debug( "in_request = $in_request : [" . $appreq->threadTrace."]", INTERNAL );
if( $in_request ) {
STATUS_NOTFOUND STATUS_NOTALLOWED STATUS_TIMEOUT
STATUS_INTERNALSERVERERROR STATUS_NOTIMPLEMENTED
STATUS_VERSIONNOTSUPPORTED STATUS_REDIRECTED
- STATUS_EXPFAILED STATUS_COMPLETE/;
+ STATUS_EXPFAILED STATUS_COMPLETE STATUS_PARTIAL
+ STATUS_NOCONTENT/;
%EXPORT_TAGS = (
status => [ qw/STATUS_CONTINUE STATUS_OK STATUS_ACCEPTED
STATUS_NOTFOUND STATUS_NOTALLOWED STATUS_TIMEOUT
STATUS_INTERNALSERVERERROR STATUS_NOTIMPLEMENTED
STATUS_VERSIONNOTSUPPORTED STATUS_REDIRECTED
- STATUS_EXPFAILED STATUS_COMPLETE/ ],
+ STATUS_EXPFAILED STATUS_COMPLETE STATUS_PARTIAL
+ STATUS_NOCONTENT/ ],
);
}
use OpenSRF::DomainObject::oilsResponse qw/:status/;
use base 'OpenSRF::DomainObject::oilsResult';
use vars qw/$status $statusCode/;
-OpenSRF::Utils::JSON->register_class_hint( hint => 'osrfResult', name => 'OpenSRF::DomainObject::oilsResult::Partial', type => 'hash' );
+OpenSRF::Utils::JSON->register_class_hint(
+ hint => 'osrfResultPartial',
+ name => 'OpenSRF::DomainObject::oilsResult::Partial',
+ type => 'hash');
$status = 'Partial Response';
use OpenSRF::DomainObject::oilsResponse qw/:status/;
use base 'OpenSRF::DomainObject::oilsResult';
use vars qw/$status $statusCode/;
-OpenSRF::Utils::JSON->register_class_hint( hint => 'osrfResult', name => 'OpenSRF::DomainObject::oilsResult::Partial', type => 'hash' );
+OpenSRF::Utils::JSON->register_class_hint(
+ hint => 'osrfResultPartialComplete',
+ name => 'OpenSRF::DomainObject::oilsResult::PartialComplete',
+ type => 'hash');
$status = 'Partial Response Finalized';