Change getMimeType and setMimeType to response->content_type.
This commit is contained in:
parent
e5adc07a05
commit
fd8f03a186
52 changed files with 138 additions and 175 deletions
|
|
@ -295,3 +295,12 @@ NEW: $session->response->status();
|
|||
|
||||
OLD: $session->http->setStatus(200);
|
||||
NEW: $session->response->status(200);
|
||||
|
||||
getMimeType and setMimeType have been removed. To set or get the content type of an HTTP response
|
||||
generated by WebGUI, access the WebGUI::Response object in the session:
|
||||
|
||||
OLD: $session->http->getMimeType();
|
||||
NEW: $session->response->content_type();
|
||||
|
||||
OLD: $session->http->setMimeType('application/json');
|
||||
NEW: $session->response->content_type('application/json');
|
||||
|
|
|
|||
|
|
@ -380,7 +380,7 @@ sub www_getFriendsAsJson {
|
|||
$results{records} = \@records;
|
||||
$results{'sort'} = 'username';
|
||||
$self->bare(1);
|
||||
$session->http->setMimeType('application/json');
|
||||
$session->response->content_type('application/json');
|
||||
my $json = JSON::to_json(\%results);
|
||||
return $json;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -599,7 +599,7 @@ sub www_getTreeData {
|
|||
};
|
||||
}
|
||||
|
||||
$session->http->setMimeType( 'application/json' );
|
||||
$session->response->content_type( 'application/json' );
|
||||
|
||||
return to_json( $assetInfo );
|
||||
}
|
||||
|
|
@ -732,7 +732,7 @@ sub www_searchAssets {
|
|||
$assetInfo->{ sort } = $session->form->get( 'orderByColumn' );
|
||||
$assetInfo->{ dir } = lc $session->form->get( 'orderByDirection' );
|
||||
|
||||
$session->http->setMimeType( 'application/json' );
|
||||
$session->response->content_type( 'application/json' );
|
||||
|
||||
return to_json( $assetInfo );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -434,10 +434,10 @@ sub www_editSubmission {
|
|||
if( $params->{asHashRef} ) {
|
||||
return { text => $content, title => $title, };
|
||||
} elsif( $session->form->get('asJson') ) {
|
||||
$session->http->setMimeType( 'application/json' );
|
||||
$session->response->content_type( 'application/json' );
|
||||
return JSON->new->encode( { text => $content, title => $title, id => $assetId ne 'new' ? $assetId : 'new' . rand } );
|
||||
} else {
|
||||
$session->http->setMimeType( 'text/html' );
|
||||
$session->response->content_type( 'text/html' );
|
||||
return $asset->processStyle( $content );
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -217,11 +217,11 @@ sub www_editSubmissionForm {
|
|||
return { text => $content, title => $title, };
|
||||
}
|
||||
elsif ( $session->form->get('asJson') ) {
|
||||
$session->http->setMimeType('application/json');
|
||||
$session->response->content_type('application/json');
|
||||
return JSON->new->encode( { text => $content, title => $title, id => 'list' . rand } );
|
||||
}
|
||||
else {
|
||||
$session->http->setMimeType('text/html');
|
||||
$session->response->content_type('text/html');
|
||||
return $parent->ems->processStyle($content);
|
||||
}
|
||||
} ## end else [ if ( scalar(@$res) == ...)]
|
||||
|
|
@ -292,10 +292,10 @@ sub www_editSubmissionForm {
|
|||
; # not setting mimie type
|
||||
}
|
||||
elsif ( $session->form->get('asJson') ) {
|
||||
$session->http->setMimeType('application/json');
|
||||
$session->response->content_type('application/json');
|
||||
}
|
||||
else {
|
||||
$session->http->setMimeType('text/html');
|
||||
$session->response->content_type('text/html');
|
||||
}
|
||||
my $content = $asset->processTemplate( {
|
||||
errors => $params->{errors} || [],
|
||||
|
|
|
|||
|
|
@ -547,7 +547,7 @@ sub www_download {
|
|||
|
||||
my $storage = $self->getStorageLocation;
|
||||
|
||||
$self->session->http->setMimeType( "image/jpeg" );
|
||||
$self->session->response->content_type( "image/jpeg" );
|
||||
$self->session->http->setLastModified( $self->getContentLastModified );
|
||||
|
||||
my $resolution = $self->session->form->get("resolution");
|
||||
|
|
|
|||
|
|
@ -857,7 +857,7 @@ sub www_getAttributes {
|
|||
|
||||
return $session->privilege->noAccess() unless $self->canView;
|
||||
|
||||
$session->http->setMimeType("application/json");
|
||||
$session->response->content_type("application/json");
|
||||
|
||||
my @results;
|
||||
my @categories = keys %{$self->getParent->getCategories};
|
||||
|
|
@ -904,7 +904,7 @@ sub www_getScreenshots {
|
|||
|
||||
return $self->session->privilege->noAccess() unless $self->canView;
|
||||
|
||||
$self->session->http->setMimeType('text/xml');
|
||||
$self->session->response->content_type('text/xml');
|
||||
|
||||
my $xml = qq |<?xml version="1.0" encoding="UTF-8"?>
|
||||
<content>
|
||||
|
|
@ -958,7 +958,7 @@ sub www_getScreenshotsConfig {
|
|||
|
||||
return $self->session->privilege->noAccess() unless $self->canView;
|
||||
|
||||
$self->session->http->setMimeType('text/xml');
|
||||
$self->session->response->content_type('text/xml');
|
||||
|
||||
return $self->processTemplate($var,$self->getParent->get("screenshotsConfigTemplateId"));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -288,7 +288,7 @@ sub www_view {
|
|||
my $self = shift;
|
||||
return $self->session->privilege->insufficient() unless $self->canView;
|
||||
my $mimeType=$self->mimeType;
|
||||
$self->session->http->setMimeType($mimeType || 'text/html');
|
||||
$self->session->response->content_type($mimeType || 'text/html');
|
||||
$self->session->http->setCacheControl($self->cacheTimeout);
|
||||
my $output = $self->view(1);
|
||||
if (!defined $output) {
|
||||
|
|
|
|||
|
|
@ -575,7 +575,7 @@ sub process {
|
|||
|
||||
# Return a JSONinfied version of vars if JSON is the only requested content type.
|
||||
if ( defined $session->request && $session->request->header('Accept') eq 'application/json' ) {
|
||||
$session->http->setMimeType( 'application/json' );
|
||||
$session->response->content_type( 'application/json' );
|
||||
return to_json( $vars );
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1816,7 +1816,7 @@ sub www_ical {
|
|||
|
||||
|
||||
# Set mime of text/icalendar
|
||||
#$self->session->http->setMimeType("text/plain");
|
||||
#$self->session->response->content_type("text/plain");
|
||||
$self->session->http->setFilename("feed.ics","text/calendar");
|
||||
return $ical;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -231,7 +231,7 @@ Get the data asynchronously.
|
|||
sub www_ajaxGetData {
|
||||
my $self = shift;
|
||||
|
||||
$self->session->http->setMimeType("application/json");
|
||||
$self->session->response->content_type("application/json");
|
||||
return $self->getDataJson;
|
||||
}
|
||||
|
||||
|
|
@ -253,7 +253,7 @@ sub www_ajaxUpdateData {
|
|||
|
||||
$data ||= $self->data;
|
||||
|
||||
$self->session->http->setMimeType("application/json");
|
||||
$self->session->response->content_type("application/json");
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -823,9 +823,9 @@ sub www_addSubmission {
|
|||
my $title = $i18n->get('select form to submit') ;
|
||||
my $asJson = $session->form->get('asJson');
|
||||
if( $asJson ) {
|
||||
$session->http->setMimeType( 'application/json' );
|
||||
$session->response->content_type( 'application/json' );
|
||||
} else {
|
||||
$session->http->setMimeType( 'text/html' );
|
||||
$session->response->content_type( 'text/html' );
|
||||
}
|
||||
my $content = '<h1>' . $title . '</h1><ul>' . $listOfLinks . '</ul>' ;
|
||||
if( $asJson ) {
|
||||
|
|
@ -1377,7 +1377,7 @@ sub www_getAllSubmissions {
|
|||
push @{ $tableInfo->{ records } }, \%fields;
|
||||
}
|
||||
|
||||
$session->http->setMimeType( 'application/json' );
|
||||
$session->response->content_type( 'application/json' );
|
||||
return JSON->new->encode( $tableInfo );
|
||||
}
|
||||
|
||||
|
|
@ -1414,7 +1414,7 @@ sub www_getBadgesAsJson {
|
|||
$results{'startIndex'} = 0;
|
||||
$results{'sort'} = undef;
|
||||
$results{'dir'} = "asc";
|
||||
$session->http->setMimeType('application/json');
|
||||
$session->response->content_type('application/json');
|
||||
return JSON->new->encode(\%results);
|
||||
}
|
||||
|
||||
|
|
@ -1444,7 +1444,7 @@ sub www_getSubmissionById {
|
|||
$result->{title} = $submissionId;
|
||||
$result->{id} = $submissionId;
|
||||
}
|
||||
$self->session->http->setMimeType('application/json');
|
||||
$self->session->response->content_type('application/json');
|
||||
return JSON->new->encode($result);
|
||||
}
|
||||
|
||||
|
|
@ -1461,7 +1461,7 @@ sub www_getRegistrantAsJson {
|
|||
my $session = $self->session;
|
||||
my $db = $session->db;
|
||||
return $session->privilege->insufficient() unless $self->canView;
|
||||
$session->http->setMimeType('application/json');
|
||||
$session->response->content_type('application/json');
|
||||
my @tickets = ();
|
||||
my @tokens = ();
|
||||
my @ribbons = ();
|
||||
|
|
@ -1640,7 +1640,7 @@ sub www_getRegistrantsAsJson {
|
|||
$results{'dir'} = "asc";
|
||||
|
||||
# build json datasource
|
||||
$session->http->setMimeType('application/json');
|
||||
$session->response->content_type('application/json');
|
||||
return JSON->new->encode(\%results);
|
||||
}
|
||||
|
||||
|
|
@ -1675,7 +1675,7 @@ sub www_getRibbonsAsJson {
|
|||
$results{'startIndex'} = 0;
|
||||
$results{'sort'} = undef;
|
||||
$results{'dir'} = "asc";
|
||||
$session->http->setMimeType('application/json');
|
||||
$session->response->content_type('application/json');
|
||||
return JSON->new->encode(\%results);
|
||||
}
|
||||
|
||||
|
|
@ -1788,7 +1788,7 @@ sub www_getScheduleDataJSON {
|
|||
$results{totalDatePages} = scalar(@dateRecords);
|
||||
$results{currentDatePage} = $datePageNumber;
|
||||
$results{dateRecords} = \@dateRecords;
|
||||
$session->http->setMimeType('application/json');
|
||||
$session->response->content_type('application/json');
|
||||
return JSON->new->encode(\%results);
|
||||
}
|
||||
|
||||
|
|
@ -1944,7 +1944,7 @@ className='WebGUI::Asset::Sku::EMSTicket' and state='published' and revisionDate
|
|||
$results{'startIndex'} = $startIndex;
|
||||
$results{'sort'} = undef;
|
||||
$results{'dir'} = "asc";
|
||||
$session->http->setMimeType('application/json');
|
||||
$session->response->content_type('application/json');
|
||||
return JSON->new->encode(\%results);
|
||||
}
|
||||
|
||||
|
|
@ -1981,7 +1981,7 @@ sub www_getTokensAsJson {
|
|||
$results{'startIndex'} = 0;
|
||||
$results{'sort'} = undef;
|
||||
$results{'dir'} = "asc";
|
||||
$session->http->setMimeType('application/json');
|
||||
$session->response->content_type('application/json');
|
||||
return JSON->new->encode(\%results);
|
||||
}
|
||||
|
||||
|
|
@ -2065,7 +2065,7 @@ sub www_importEventsSave {
|
|||
$|=1;
|
||||
|
||||
# set up
|
||||
$session->http->setMimeType("text/plain");
|
||||
$session->response->content_type("text/plain");
|
||||
my $start = [Time::HiRes::gettimeofday];
|
||||
my $i18n = WebGUI::International->new($session,'Asset_EventManagementSystem');
|
||||
my $csv = Text::CSV_XS->new({ binary => 1 });
|
||||
|
|
|
|||
|
|
@ -1145,11 +1145,11 @@ sub www_addAlbumService {
|
|||
lastUpdated => $date->epochToHuman($album->revisionDate, '%y-%m-%d %j:%n:%s'),
|
||||
};
|
||||
if ($as eq "xml") {
|
||||
$session->http->setMimeType('text/xml');
|
||||
$session->response->content_type('text/xml');
|
||||
return XML::Simple::XMLout($document, NoAttr => 1);
|
||||
}
|
||||
|
||||
$session->http->setMimeType('application/json');
|
||||
$session->response->content_type('application/json');
|
||||
return JSON->new->pretty->encode($document);
|
||||
}
|
||||
|
||||
|
|
@ -1206,7 +1206,7 @@ sub www_listAlbumsRss {
|
|||
push @{ $var->{albums} }, $assetVar;
|
||||
}
|
||||
|
||||
$self->session->http->setMimeType('text/xml');
|
||||
$self->session->response->content_type('text/xml');
|
||||
return $self->processTemplate( $var, $self->templateIdListAlbumsRss );
|
||||
}
|
||||
|
||||
|
|
@ -1344,10 +1344,10 @@ sub www_listAlbumsService {
|
|||
albums => \@assets
|
||||
};
|
||||
if ($as eq "xml") {
|
||||
$session->http->setMimeType('text/xml');
|
||||
$session->response->content_type('text/xml');
|
||||
return XML::Simple::XMLout($document, NoAttr => 1);
|
||||
}
|
||||
$session->http->setMimeType('application/json');
|
||||
$session->response->content_type('application/json');
|
||||
return JSON->new->pretty->encode($document);
|
||||
}
|
||||
|
||||
|
|
@ -1612,7 +1612,7 @@ sub www_listFilesForUserRss {
|
|||
push @{ $var->{user_files} }, $assetVar;
|
||||
}
|
||||
|
||||
$self->session->http->setMimeType('text/xml');
|
||||
$self->session->response->content_type('text/xml');
|
||||
return $self->processTemplate( $var, $self->templateIdListFilesForUserRss );
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1159,11 +1159,11 @@ sub www_addFileService {
|
|||
lastUpdated => $date->epochToHuman($file->revisionDate, '%y-%m-%d %j:%n:%s'),
|
||||
};
|
||||
if ($as eq "xml") {
|
||||
$session->http->setMimeType('text/xml');
|
||||
$session->response->content_type('text/xml');
|
||||
return XML::Simple::XMLout($document, NoAttr => 1);
|
||||
}
|
||||
|
||||
$session->http->setMimeType('application/json');
|
||||
$session->response->content_type('application/json');
|
||||
return JSON->new->pretty->encode($document);
|
||||
}
|
||||
|
||||
|
|
@ -1739,7 +1739,7 @@ sub www_viewRss {
|
|||
= $self->session->datetime->epochToMail( $file->{creationDate} );
|
||||
}
|
||||
|
||||
$self->session->http->setMimeType('text/xml');
|
||||
$self->session->response->content_type('text/xml');
|
||||
return $self->processTemplate( $var, $self->getParent->templateIdViewAlbumRss );
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -466,7 +466,7 @@ sub view {
|
|||
}
|
||||
|
||||
|
||||
$self->session->http->setMimeType($var{header});
|
||||
$self->session->response->content_type($var{header});
|
||||
|
||||
if($var{header} ne "text/html") {
|
||||
return $var{content};
|
||||
|
|
@ -494,7 +494,7 @@ sub www_view {
|
|||
return $self->session->privilege->noAccess() unless $self->canView;
|
||||
$self->prepareView;
|
||||
my $output = $self->view;
|
||||
if ($self->session->http->getMimeType ne "text/html") {
|
||||
if ($self->session->response->content_type ne "text/html") {
|
||||
return $output;
|
||||
} else {
|
||||
$self->session->http->sendHeader;
|
||||
|
|
|
|||
|
|
@ -482,7 +482,7 @@ sub www_ajaxDeletePoint {
|
|||
my $i18n = WebGUI::International->new( $session, 'Asset_Map' );
|
||||
my $assetId = $session->form->get('assetId');
|
||||
my $asset = WebGUI::Asset->newById( $session, $assetId );
|
||||
$session->http->setMimeType('application/json');
|
||||
$session->response->content_type('application/json');
|
||||
return JSON->new->encode({error => $i18n->get('error delete unauthorized')})
|
||||
unless $asset && $asset->canEdit;
|
||||
|
||||
|
|
@ -535,7 +535,7 @@ sub www_ajaxEditPointSave {
|
|||
|
||||
# We're returning as HTML because application/json causes download pop-up
|
||||
# and text/plain causes <pre>...</pre> in firefox
|
||||
$session->http->setMimeType("text/html");
|
||||
$session->response->content_type("text/html");
|
||||
$session->log->preventDebugOutput;
|
||||
|
||||
my $assetId = $form->get('assetId');
|
||||
|
|
@ -591,7 +591,7 @@ sub www_ajaxSetCenter {
|
|||
my $form = $self->session->form;
|
||||
my $i18n = WebGUI::International->new( $session, 'Asset_Map' );
|
||||
|
||||
$session->http->setMimeType("application/json");
|
||||
$session->response->content_type("application/json");
|
||||
|
||||
return JSON->new->encode({message => $i18n->get("error set center unauthorized")})
|
||||
unless $self->canEdit;
|
||||
|
|
@ -619,7 +619,7 @@ sub www_ajaxSetPointLocation {
|
|||
my $form = $self->session->form;
|
||||
my $i18n = WebGUI::International->new( $session, 'Asset_Map' );
|
||||
|
||||
$session->http->setMimeType("application/json");
|
||||
$session->response->content_type("application/json");
|
||||
|
||||
my $assetId = $form->get('assetId');
|
||||
my $asset = WebGUI::Asset->newById( $session, $assetId );
|
||||
|
|
|
|||
|
|
@ -1109,7 +1109,7 @@ sub www_getCompareFormData {
|
|||
|
||||
my @listingIds = $session->form->checkList("listingId");
|
||||
|
||||
$session->http->setMimeType("application/json");
|
||||
$session->response->content_type("application/json");
|
||||
my $db = $session->db;
|
||||
|
||||
my (@searchParams,@searchParams_sorted,@searchParamList,$searchParamList);
|
||||
|
|
@ -1301,7 +1301,7 @@ sub www_getCompareListData {
|
|||
}
|
||||
|
||||
$jsonOutput->{ResultSet} = {Result=>\@results};
|
||||
$session->http->setMimeType("application/json");
|
||||
$session->response->content_type("application/json");
|
||||
|
||||
return JSON->new->encode($jsonOutput);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -577,7 +577,7 @@ override www_view => sub {
|
|||
}
|
||||
else {
|
||||
$self->prepareView();
|
||||
$self->session->http->setMimeType($mimeType);
|
||||
$self->session->response->content_type($mimeType);
|
||||
return $self->view();
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1295,7 +1295,7 @@ sub www_loadSurvey {
|
|||
warnings => $warnings #List of warnings to display to the user
|
||||
};
|
||||
|
||||
$self->session->http->setMimeType('application/json');
|
||||
$self->session->response->content_type('application/json');
|
||||
|
||||
return to_json($return);
|
||||
}
|
||||
|
|
@ -1762,7 +1762,7 @@ sub www_loadQuestions {
|
|||
if(! $self->session->form->param('shownsummary')){
|
||||
my ($summary,$html) = $self->getSummary();
|
||||
my $json = to_json( { type => 'summary', summary => $summary, html => $html });
|
||||
$self->session->http->setMimeType('application/json');
|
||||
$self->session->response->content_type('application/json');
|
||||
return $json;
|
||||
}
|
||||
}
|
||||
|
|
@ -1869,7 +1869,7 @@ sub surveyEnd {
|
|||
$exitUrl = $exitUrl || $self->exitURL || $self->getUrl || q{/};
|
||||
$exitUrl = $self->session->url->gateway($exitUrl) if($exitUrl !~ /^https?:/i);
|
||||
my $json = to_json( { type => 'forward', url => $exitUrl } );
|
||||
$self->session->http->setMimeType('application/json');
|
||||
$self->session->response->content_type('application/json');
|
||||
return $json;
|
||||
}
|
||||
|
||||
|
|
@ -1963,7 +1963,7 @@ sub prepareShowSurveyTemplate {
|
|||
my $out = $self->processTemplate( $section, $self->surveyQuestionsId );
|
||||
WebGUI::Macro::process($self->session, \$out);
|
||||
|
||||
$self->session->http->setMimeType('application/json');
|
||||
$self->session->response->content_type('application/json');
|
||||
return to_json( { type => 'displayquestions', section => $section, questions => $questions, html => $out } );
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1621,7 +1621,7 @@ sub www_deleteThingDataViaAjax {
|
|||
my $thingId = $self->session->form->process("thingId");
|
||||
my $thingDataId = $self->session->form->process('thingDataId');
|
||||
|
||||
$session->http->setMimeType("application/json");
|
||||
$session->response->content_type("application/json");
|
||||
|
||||
unless ($thingId && $thingDataId) {
|
||||
$session->response->status(400);
|
||||
|
|
@ -1635,7 +1635,7 @@ sub www_deleteThingDataViaAjax {
|
|||
|
||||
$self->deleteThingData($thingId,$thingDataId);
|
||||
|
||||
$session->http->setMimeType("application/json");
|
||||
$session->response->content_type("application/json");
|
||||
return JSON->new->encode({message => "Data with thingDataId $thingDataId was deleted."});
|
||||
}
|
||||
else {
|
||||
|
|
@ -2704,7 +2704,7 @@ sub www_getThingViaAjax {
|
|||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
my $thingId = shift || $session->form->process('thingId');
|
||||
$session->http->setMimeType("application/json");
|
||||
$session->response->content_type("application/json");
|
||||
|
||||
unless ($thingId) {
|
||||
$session->response->status(400);
|
||||
|
|
@ -2725,7 +2725,7 @@ sub www_getThingViaAjax {
|
|||
}
|
||||
$thingProperties->{field_loop} = \@field_loop;
|
||||
|
||||
$session->http->setMimeType("application/json");
|
||||
$session->response->content_type("application/json");
|
||||
return JSON->new->encode($thingProperties);
|
||||
}
|
||||
else {
|
||||
|
|
@ -2747,7 +2747,7 @@ sub www_getThingsViaAjax {
|
|||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
|
||||
$session->http->setMimeType("application/json");
|
||||
$session->response->content_type("application/json");
|
||||
|
||||
my @visibleThings;
|
||||
my $things = $self->getThings;
|
||||
|
|
@ -3134,7 +3134,7 @@ sub www_searchViaAjax {
|
|||
|
||||
my $var = $self->getSearchTemplateVars($thingId,$thingProperties);
|
||||
|
||||
$session->http->setMimeType("application/json");
|
||||
$session->response->content_type("application/json");
|
||||
return JSON->new->encode($var);
|
||||
}
|
||||
else {
|
||||
|
|
@ -3554,7 +3554,7 @@ sub www_viewThingDataViaAjax {
|
|||
my $thingId = shift || $session->form->process('thingId');
|
||||
my $thingDataId = shift || $session->form->process('thingDataId');
|
||||
|
||||
$session->http->setMimeType("application/json");
|
||||
$session->response->content_type("application/json");
|
||||
|
||||
unless ($thingId && $thingDataId) {
|
||||
$session->response->status(400);
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ sub handler {
|
|||
else {
|
||||
$session->log->warn("User ".$session->user->username." tried to execute ajaxGetI18n but could not decode JSON string: $json");
|
||||
}
|
||||
$session->http->setMimeType( "application/json" );
|
||||
$session->response->content_type( "application/json" );
|
||||
return JSON->new->encode( $response );
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -134,10 +134,10 @@ sub handler {
|
|||
assets => \@assets
|
||||
};
|
||||
if ($as eq "xml") {
|
||||
$session->http->setMimeType('text/xml');
|
||||
$session->response->content_type('text/xml');
|
||||
return XML::Simple::XMLout($document, NoAttr => 1);
|
||||
}
|
||||
$session->http->setMimeType('application/json');
|
||||
$session->response->content_type('application/json');
|
||||
return JSON->new->encode($document);
|
||||
}
|
||||
return undef;
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ EOSQL
|
|||
$results{'startIndex'} = $startIndex;
|
||||
$results{'sort'} = undef;
|
||||
$results{'dir'} = $sortDir;
|
||||
$session->http->setMimeType('application/json');
|
||||
$session->response->content_type('application/json');
|
||||
my $json = JSON::to_json(\%results);
|
||||
return $json;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -315,7 +315,7 @@ sub www_ajaxGetManagerPage {
|
|||
$assetInfo->{ sort } = $session->form->get( 'orderByColumn' );
|
||||
$assetInfo->{ dir } = lc $session->form->get( 'orderByDirection' );
|
||||
|
||||
$session->http->setMimeType( 'application/json' );
|
||||
$session->response->content_type( 'application/json' );
|
||||
|
||||
return to_json( $assetInfo );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ sub handler {
|
|||
.'</urlset>';
|
||||
|
||||
|
||||
$session->http->setMimeType('text/xml');
|
||||
$session->response->content_type('text/xml');
|
||||
|
||||
return $xml;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ sub handler {
|
|||
finished => ( $finished ? \1 : \0 ),
|
||||
);
|
||||
$status{error} = $error if $finished;
|
||||
$process->session->http->setMimeType('text/plain');
|
||||
$process->session->response->content_type('text/plain');
|
||||
JSON::encode_json( \%status );
|
||||
} ## end sub handler
|
||||
|
||||
|
|
|
|||
|
|
@ -149,7 +149,7 @@ sub www_searchAsJSON {
|
|||
my $keyword = WebGUI::Keyword->new($session);
|
||||
|
||||
my $keywords = $keyword->findKeywords({search => $search, limit => 20});
|
||||
$session->http->setMimeType('application/json');
|
||||
$session->response->content_type('application/json');
|
||||
|
||||
return JSON::to_json({keywords => $keywords});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ sub www_getThingFields {
|
|||
[$thingId]
|
||||
);
|
||||
|
||||
$session->http->setMimeType( 'application/json' );
|
||||
$session->response->content_type( 'application/json' );
|
||||
return JSON->new->encode( \%fields );
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -138,7 +138,7 @@ sub www_check {
|
|||
my $session = shift;
|
||||
my $input = $session->form->param('input');
|
||||
|
||||
$session->http->setMimeType( 'application/json' );
|
||||
$session->response->content_type( 'application/json' );
|
||||
my $i18n = WebGUI::International->new($session, 'Form_Username');
|
||||
|
||||
my $error = '';
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ sub www_auth {
|
|||
my $method = $authMethod->can( 'www_' . $methodCall )
|
||||
|| $authMethod->can( $methodCall );
|
||||
my $out = $method->( $authMethod );
|
||||
if (substr($session->http->getMimeType(),0,9) eq "text/html") {
|
||||
if (substr($session->response->content_type(),0,9) eq "text/html") {
|
||||
return $session->style->userStyle($out);
|
||||
}
|
||||
else {
|
||||
|
|
|
|||
|
|
@ -269,7 +269,7 @@ Checks to ensure the requestor is who we think it is, and then executes a cron j
|
|||
|
||||
sub www_runCronJob {
|
||||
my $session = shift;
|
||||
$session->http->setMimeType("text/plain");
|
||||
$session->response->content_type("text/plain");
|
||||
$session->http->setCacheControl("none");
|
||||
unless (Net::CIDR::Lite->new(@{ $session->config->get('spectreSubnets') })->find($session->request->address) || canView($session)) {
|
||||
$session->log->security("make a Spectre cron job runner request, but we're only allowed to accept requests from ".join(",",@{$session->config->get("spectreSubnets")}).".");
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ Checks to ensure the requestor is who we think it is, and then returns a JSON st
|
|||
|
||||
sub www_spectreGetSiteData {
|
||||
my $session = shift;
|
||||
$session->http->setMimeType("application/json");
|
||||
$session->response->content_type("application/json");
|
||||
$session->http->setCacheControl("none");
|
||||
my %siteData = ();
|
||||
my $subnets = $session->config->get("spectreSubnets");
|
||||
|
|
@ -173,7 +173,7 @@ spectreSubnet, instead of checking the IP address of the spectre process.
|
|||
|
||||
sub www_spectreTest {
|
||||
my $session = shift;
|
||||
$session->http->setMimeType("text/plain");
|
||||
$session->response->content_type("text/plain");
|
||||
$session->http->setCacheControl("none");
|
||||
|
||||
my $subnets = $session->config->get("spectreSubnets");
|
||||
|
|
|
|||
|
|
@ -222,7 +222,7 @@ sub www_spellCheck {
|
|||
}
|
||||
# add request id and send to client as JSON blob
|
||||
$result->{id} = $params->{id};
|
||||
$session->http->setMimeType("text/plain; charset=utf-8");
|
||||
$session->response->content_type("text/plain; charset=utf-8");
|
||||
return JSON->new->encode($result);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -349,7 +349,7 @@ sub www_ajaxCreateUser {
|
|||
$mimeType = "application/xml";
|
||||
}
|
||||
|
||||
$session->http->setMimeType( $mimeType );
|
||||
$session->response->content_type( $mimeType );
|
||||
|
||||
# Verify access
|
||||
if ( !canAdd($session) || !canUseService($session) ) {
|
||||
|
|
@ -436,7 +436,7 @@ sub www_ajaxDeleteUser {
|
|||
$mimeType = "application/xml";
|
||||
}
|
||||
|
||||
$session->http->setMimeType( $mimeType );
|
||||
$session->response->content_type( $mimeType );
|
||||
|
||||
# Verify access
|
||||
if ( !canEdit($session) || !canUseService($session) ) {
|
||||
|
|
@ -503,7 +503,7 @@ sub www_ajaxUpdateUser {
|
|||
$mimeType = "application/xml";
|
||||
}
|
||||
|
||||
$session->http->setMimeType( $mimeType );
|
||||
$session->response->content_type( $mimeType );
|
||||
|
||||
# Verify access
|
||||
if ( !canEdit($session) || !canUseService($session) ) {
|
||||
|
|
|
|||
|
|
@ -480,7 +480,7 @@ Checks to ensure the requestor is who we think it is, and then executes a workfl
|
|||
|
||||
sub www_runWorkflow {
|
||||
my $session = shift;
|
||||
$session->http->setMimeType("text/plain");
|
||||
$session->response->content_type("text/plain");
|
||||
$session->http->setCacheControl("none");
|
||||
unless (Net::CIDR::Lite->new(@{ $session->config->get('spectreSubnets')} )->find($session->request->address) || canRunWorkflow($session)) {
|
||||
$session->log->security("make a Spectre workflow runner request, but we're only allowed to accept requests from ".join(",",@{$session->config->get("spectreSubnets")}).".");
|
||||
|
|
|
|||
|
|
@ -559,7 +559,7 @@ Return Atom view of the syndicated items.
|
|||
sub www_viewAtom {
|
||||
my $self = shift;
|
||||
return $self->_httpBasicLogin unless $self->canView;
|
||||
$self->session->http->setMimeType('application/atom+xml');
|
||||
$self->session->response->content_type('application/atom+xml');
|
||||
return $self->getFeed( XML::FeedPP::Atom->new )->to_string;
|
||||
}
|
||||
|
||||
|
|
@ -574,7 +574,7 @@ Return Rdf view of the syndicated items.
|
|||
sub www_viewRdf {
|
||||
my $self = shift;
|
||||
return $self->_httpBasicLogin unless $self->canView;
|
||||
$self->session->http->setMimeType('application/rdf+xml');
|
||||
$self->session->response->content_type('application/rdf+xml');
|
||||
return $self->getFeed( XML::FeedPP::RDF->new )->to_string;
|
||||
}
|
||||
|
||||
|
|
@ -589,7 +589,7 @@ Return RSS view of the syndicated items.
|
|||
sub www_viewRss {
|
||||
my $self = shift;
|
||||
return $self->_httpBasicLogin unless $self->canView;
|
||||
$self->session->http->setMimeType('application/rss+xml');
|
||||
$self->session->response->content_type('application/rss+xml');
|
||||
return $self->getFeed( XML::FeedPP::RSS->new )->to_string;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -568,7 +568,9 @@ sub open {
|
|||
|
||||
my $request = WebGUI::Session::Request->new($env);
|
||||
$self->{_request} = $request;
|
||||
##Set defaults
|
||||
$self->{_response} = $request->new_response( 200 );
|
||||
$self->{_response}->content_type('text/html; charset=UTF-8');
|
||||
|
||||
# Use the WebGUI::Session::Request object to look up the sessionId from cookies, if it
|
||||
# wasn't given explicitly
|
||||
|
|
|
|||
|
|
@ -41,12 +41,10 @@ This package allows the manipulation of HTTP protocol information.
|
|||
|
||||
$http->sendHeader();
|
||||
|
||||
$mimetype = $http->getMimeType();
|
||||
$boolean = $http->isRedirect();
|
||||
|
||||
$http->setCookie($name,$value);
|
||||
$http->setFilename($filename,$mimetype);
|
||||
$http->setMimeType($mimetype);
|
||||
$http->setNoHeader($bool);
|
||||
$http->setRedirect($url);
|
||||
|
||||
|
|
@ -99,19 +97,6 @@ sub getLastModified {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getMimeType ( )
|
||||
|
||||
Returns the current mime type of the document to be returned.
|
||||
|
||||
=cut
|
||||
|
||||
sub getMimeType {
|
||||
my $self = shift;
|
||||
return $self->{_http}{mimetype} || "text/html; charset=UTF-8";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getNoHeader ( )
|
||||
|
||||
Returns whether or not a HTTP header will be printed.
|
||||
|
|
@ -248,7 +233,6 @@ sub sendHeader {
|
|||
if ($self->isRedirect()) {
|
||||
$response->header(Location => $self->getRedirectLocation);
|
||||
} else {
|
||||
$response->content_type($self->getMimeType);
|
||||
my $cacheControl = $self->getCacheControl;
|
||||
my $date = ($userId eq "1") ? HTTP::Date::time2str($self->getLastModified) : HTTP::Date::time2str();
|
||||
# under these circumstances, don't allow caching
|
||||
|
|
@ -373,7 +357,7 @@ sub setCookie {
|
|||
|
||||
=head2 setFilename ( filename [, mimetype] )
|
||||
|
||||
Override the default filename for the document, which is usually the page url. Usually used with setMimeType().
|
||||
Override the default filename for the document, which is usually the page url.
|
||||
|
||||
=head3 filename
|
||||
|
||||
|
|
@ -389,7 +373,7 @@ sub setFilename {
|
|||
my $self = shift;
|
||||
$self->{_http}{filename} = shift;
|
||||
my $mimetype = shift || "application/octet-stream";
|
||||
$self->setMimeType($mimetype);
|
||||
$self->session->response->content_type($mimetype);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -427,25 +411,6 @@ sub setLastModified {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 setMimeType ( mimetype )
|
||||
|
||||
Override mime type for the document, which is defaultly "text/html; charset=UTF-8". Also see setFilename().
|
||||
|
||||
B<NOTE:> By setting the mime type to something other than "text/html" WebGUI will automatically not process the normal page contents. Instead it will return only the content of your Wobject function or Operation.
|
||||
|
||||
=head3 mimetype
|
||||
|
||||
The mime type for the document.
|
||||
|
||||
=cut
|
||||
|
||||
sub setMimeType {
|
||||
my $self = shift;
|
||||
$self->{_http}{mimetype} = shift;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 setNoHeader ( boolean )
|
||||
|
||||
Disables the printing of a HTTP header. Useful in situations when content is not
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ has been set to a non-text type, macros will automatically be skipped.
|
|||
sub print {
|
||||
my $self = shift;
|
||||
my $content = shift;
|
||||
my $skipMacros = shift || !($self->session->http->getMimeType =~ /^text/);
|
||||
my $skipMacros = shift || !($self->session->response->content_type =~ /^text/);
|
||||
WebGUI::Macro::process($self->session, \$content) unless $skipMacros;
|
||||
my $handle = $self->{_handle};
|
||||
if (defined $handle) {
|
||||
|
|
|
|||
|
|
@ -527,7 +527,7 @@ parameter
|
|||
sub www_ajaxGetAddress {
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
$session->http->setMimeType('text/plain');
|
||||
$session->response->content_type('text/plain');
|
||||
|
||||
my $addressId = $session->form->get('addressId');
|
||||
my $address = $self->getAddress($addressId) or return;
|
||||
|
|
@ -553,7 +553,7 @@ sub www_ajaxSave {
|
|||
else {
|
||||
$obj = $self->addAddress($address);
|
||||
}
|
||||
$session->http->setMimeType('text/plain');
|
||||
$session->response->content_type('text/plain');
|
||||
return $obj->getId;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -942,7 +942,7 @@ sub www_ajaxPrices {
|
|||
$ship->getOptions($self);
|
||||
} || [],
|
||||
};
|
||||
$session->http->setMimeType('text/plain');
|
||||
$session->response->content_type('text/plain');
|
||||
return JSON->new->encode($response);
|
||||
}
|
||||
|
||||
|
|
@ -961,7 +961,7 @@ sub www_ajaxSetCartItemShippingId {
|
|||
my $item = $self->getItem($form->get('itemId'));
|
||||
my $address = $form->get('addressId') || undef;
|
||||
$item && $item->update({ shippingAddressId => $address });
|
||||
$session->http->setMimeType('text/plain');
|
||||
$session->response->content_type('text/plain');
|
||||
return 'ok';
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -699,7 +699,7 @@ do whatever other activity a Sku purchase would allow.
|
|||
sub www_processRecurringTransactionPostback {
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
$session->http->setMimeType('text/plain');
|
||||
$session->response->content_type('text/plain');
|
||||
my $form = $session->form;
|
||||
|
||||
# Get posted data of interest
|
||||
|
|
|
|||
|
|
@ -1079,7 +1079,7 @@ sub www_getTaxGroupsAsJSON {
|
|||
$group->{ isDefault } = 1 if $id eq $self->get( 'defaultGroup' );
|
||||
}
|
||||
|
||||
$self->session->http->setMimeType( 'application/json' );
|
||||
$self->session->response->content_type( 'application/json' );
|
||||
return to_json( { records => $taxGroups } );
|
||||
}
|
||||
|
||||
|
|
@ -1158,7 +1158,7 @@ sub www_getVATNumbersAsJSON {
|
|||
push @numbers, $number;
|
||||
}
|
||||
|
||||
$self->session->http->setMimeType( 'application/json' );
|
||||
$self->session->response->content_type( 'application/json' );
|
||||
return to_json( { records => \@numbers } );
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -486,7 +486,7 @@ sub www_getTaxesAsJson {
|
|||
$results{'startIndex'} = $startIndex;
|
||||
$results{'sort'} = undef;
|
||||
$results{'dir'} = $sortDir;
|
||||
$session->http->setMimeType('application/json');
|
||||
$session->response->content_type('application/json');
|
||||
return JSON::to_json(\%results);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1069,7 +1069,7 @@ sub www_getTransactionsAsJson {
|
|||
$results{'startIndex'} = $startIndex;
|
||||
$results{'sort'} = undef;
|
||||
$results{'dir'} = "desc";
|
||||
$session->http->setMimeType('application/json');
|
||||
$session->response->content_type('application/json');
|
||||
return JSON->new->encode(\%results);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -619,7 +619,7 @@ sub www_payoutDataAsJSON {
|
|||
results => $paginator->getPageData,
|
||||
};
|
||||
|
||||
$session->http->setMimeType( 'application/json' );
|
||||
$session->response->content_type( 'application/json' );
|
||||
|
||||
return JSON::to_json( $data );
|
||||
}
|
||||
|
|
@ -665,7 +665,7 @@ sub www_setPayoutStatus {
|
|||
$item->update({ vendorPayoutStatus => $status });
|
||||
}
|
||||
|
||||
$session->http->setMimeType( 'text/plain' );
|
||||
$session->response->content_type( 'text/plain' );
|
||||
return $status;
|
||||
}
|
||||
|
||||
|
|
@ -745,7 +745,7 @@ sub www_vendorTotalsAsJSON {
|
|||
push @dataset, $dataset;
|
||||
}
|
||||
|
||||
$session->http->setMimeType( 'application/json' );
|
||||
$session->response->content_type( 'application/json' );
|
||||
return JSON::to_json( { vendors => \@dataset } );
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ label.formDescription { display: block; margin-top: 1em; font-weight: bold }
|
|||
</head>
|
||||
<body><div id="wrapper"> ' . $output . ' </div></body>
|
||||
</html>';
|
||||
$session->http->setMimeType("text/html");
|
||||
$session->response->content_type("text/html");
|
||||
return $page;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ plan tests => 56; # Increment this number for each test you create
|
|||
# - user
|
||||
$session->user({ userId => 1 });
|
||||
$response = WebGUI::Operation::User::www_ajaxCreateUser( $session );
|
||||
is( $session->http->getMimeType, 'application/json', "Correct mime type (default: json)" );
|
||||
is( $session->response->content_type, 'application/json', "Correct mime type (default: json)" );
|
||||
cmp_deeply(
|
||||
JSON->new->decode( $response ),
|
||||
{
|
||||
|
|
@ -61,7 +61,7 @@ $session->request->setup_body({
|
|||
as => "xml",
|
||||
});
|
||||
$response = WebGUI::Operation::User::www_ajaxCreateUser( $session );
|
||||
is( $session->http->getMimeType, 'application/xml', "Correct mime type (as => xml)" );
|
||||
is( $session->response->content_type, 'application/xml', "Correct mime type (as => xml)" );
|
||||
cmp_deeply(
|
||||
XML::Simple::XMLin( $response ),
|
||||
{
|
||||
|
|
@ -82,7 +82,7 @@ $session->request->setup_body({
|
|||
});
|
||||
$session->user({ userId => 3 });
|
||||
$response = WebGUI::Operation::User::www_ajaxCreateUser( $session );
|
||||
is( $session->http->getMimeType, 'application/json', "Correct mime type (as => json)" );
|
||||
is( $session->response->content_type, 'application/json', "Correct mime type (as => json)" );
|
||||
cmp_deeply(
|
||||
JSON->new->decode( $response ),
|
||||
{
|
||||
|
|
@ -99,7 +99,7 @@ $session->request->setup_body({
|
|||
firstName => 'Jake',
|
||||
});
|
||||
$response = WebGUI::Operation::User::www_ajaxCreateUser( $session );
|
||||
is( $session->http->getMimeType, 'application/json', "Correct mime type (default: json)" );
|
||||
is( $session->response->content_type, 'application/json', "Correct mime type (default: json)" );
|
||||
cmp_deeply(
|
||||
JSON->new->decode( $response ),
|
||||
{
|
||||
|
|
@ -121,7 +121,7 @@ $session->request->setup_body({
|
|||
'auth:LDAP:connectDN' => 'u=andy;o=block-e;dc=shawshank;dc=me',
|
||||
});
|
||||
$response = WebGUI::Operation::User::www_ajaxCreateUser( $session );
|
||||
is( $session->http->getMimeType, 'application/json', "Correct mime type (default: json" );
|
||||
is( $session->response->content_type, 'application/json', "Correct mime type (default: json" );
|
||||
$responseObj = JSON->new->decode( $response );
|
||||
cmp_deeply(
|
||||
$responseObj,
|
||||
|
|
@ -153,7 +153,7 @@ $session->request->setup_body({
|
|||
'auth:LDAP:connectDN' => 'u=red;o=block-e;dc=shawshank;dc=me',
|
||||
});
|
||||
$response = WebGUI::Operation::User::www_ajaxCreateUser( $session );
|
||||
is( $session->http->getMimeType, 'application/json', "Correct mime type (default: json" );
|
||||
is( $session->response->content_type, 'application/json', "Correct mime type (default: json" );
|
||||
$responseObj = JSON->new->decode( $response );
|
||||
cmp_deeply(
|
||||
$responseObj,
|
||||
|
|
@ -183,7 +183,7 @@ is( $auth->getParams->{connectDN}, 'u=red;o=block-e;dc=shawshank;dc=me', "Auth p
|
|||
# - user
|
||||
$session->user({ userId => 1 });
|
||||
$response = WebGUI::Operation::User::www_ajaxUpdateUser( $session );
|
||||
is( $session->http->getMimeType, 'application/json', "Correct mime type (default: json)" );
|
||||
is( $session->response->content_type, 'application/json', "Correct mime type (default: json)" );
|
||||
cmp_deeply(
|
||||
JSON->new->decode( $response ),
|
||||
{
|
||||
|
|
@ -201,7 +201,7 @@ $session->request->setup_body({
|
|||
as => "xml",
|
||||
});
|
||||
$response = WebGUI::Operation::User::www_ajaxUpdateUser( $session );
|
||||
is( $session->http->getMimeType, 'application/xml', "Correct mime type (as => xml)" );
|
||||
is( $session->response->content_type, 'application/xml', "Correct mime type (as => xml)" );
|
||||
cmp_deeply(
|
||||
XML::Simple::XMLin( $response ),
|
||||
{
|
||||
|
|
@ -222,7 +222,7 @@ $session->request->setup_body({
|
|||
});
|
||||
$session->user({ userId => 3 });
|
||||
$response = WebGUI::Operation::User::www_ajaxUpdateUser( $session );
|
||||
is( $session->http->getMimeType, 'application/json', "Correct mime type (as => json)" );
|
||||
is( $session->response->content_type, 'application/json', "Correct mime type (as => json)" );
|
||||
cmp_deeply(
|
||||
JSON->new->decode( $response ),
|
||||
{
|
||||
|
|
@ -241,7 +241,7 @@ $session->request->setup_body({
|
|||
});
|
||||
$session->user({ userId => 3 });
|
||||
$response = WebGUI::Operation::User::www_ajaxUpdateUser( $session );
|
||||
is( $session->http->getMimeType, 'application/json', "Correct mime type (default: json)" );
|
||||
is( $session->response->content_type, 'application/json', "Correct mime type (default: json)" );
|
||||
cmp_deeply(
|
||||
JSON->new->decode( $response ),
|
||||
{
|
||||
|
|
@ -263,7 +263,7 @@ $session->request->setup_body({
|
|||
'auth:LDAP:connectDN' => 'u=rich;o=escapee;dc=shawshank;dc=me',
|
||||
});
|
||||
$response = WebGUI::Operation::User::www_ajaxUpdateUser( $session );
|
||||
is( $session->http->getMimeType, 'application/json', "Correct mime type (default: json" );
|
||||
is( $session->response->content_type, 'application/json', "Correct mime type (default: json" );
|
||||
$responseObj = JSON->new->decode( $response );
|
||||
cmp_deeply(
|
||||
$responseObj,
|
||||
|
|
@ -294,7 +294,7 @@ $session->request->setup_body({
|
|||
'auth:LDAP:connectDN' => 'u=red;o=parollee;dc=shawshank;dc=me',
|
||||
});
|
||||
$response = WebGUI::Operation::User::www_ajaxUpdateUser( $session );
|
||||
is( $session->http->getMimeType, 'application/json', "Correct mime type (default: json" );
|
||||
is( $session->response->content_type, 'application/json', "Correct mime type (default: json" );
|
||||
$responseObj = JSON->new->decode( $response );
|
||||
cmp_deeply(
|
||||
$responseObj,
|
||||
|
|
@ -323,7 +323,7 @@ is( $auth->getParams->{connectDN}, 'u=red;o=parollee;dc=shawshank;dc=me', "Auth
|
|||
# - user
|
||||
$session->user({ userId => 1 });
|
||||
$response = WebGUI::Operation::User::www_ajaxDeleteUser( $session );
|
||||
is( $session->http->getMimeType, 'application/json', "Correct mime type (default: json)" );
|
||||
is( $session->response->content_type, 'application/json', "Correct mime type (default: json)" );
|
||||
cmp_deeply(
|
||||
JSON->new->decode( $response ),
|
||||
{
|
||||
|
|
@ -341,7 +341,7 @@ $session->request->setup_body({
|
|||
as => "xml",
|
||||
});
|
||||
$response = WebGUI::Operation::User::www_ajaxDeleteUser( $session );
|
||||
is( $session->http->getMimeType, 'application/xml', "Correct mime type (as => xml)" );
|
||||
is( $session->response->content_type, 'application/xml', "Correct mime type (as => xml)" );
|
||||
cmp_deeply(
|
||||
XML::Simple::XMLin( $response ),
|
||||
{
|
||||
|
|
@ -360,7 +360,7 @@ $session->request->setup_body({
|
|||
});
|
||||
$session->user({ userId => 3 });
|
||||
$response = WebGUI::Operation::User::www_ajaxDeleteUser( $session );
|
||||
is( $session->http->getMimeType, 'application/json', "Correct mime type (as => json)" );
|
||||
is( $session->response->content_type, 'application/json', "Correct mime type (as => json)" );
|
||||
cmp_deeply(
|
||||
JSON->new->decode( $response ),
|
||||
{
|
||||
|
|
@ -377,7 +377,7 @@ $session->request->setup_body({
|
|||
});
|
||||
$session->user({ userId => 3 });
|
||||
$response = WebGUI::Operation::User::www_ajaxDeleteUser( $session );
|
||||
is( $session->http->getMimeType, 'application/json', "Correct mime type (default: json)" );
|
||||
is( $session->response->content_type, 'application/json', "Correct mime type (default: json)" );
|
||||
cmp_deeply(
|
||||
JSON->new->decode( $response ),
|
||||
{
|
||||
|
|
@ -394,7 +394,7 @@ $session->request->setup_body({
|
|||
});
|
||||
$session->user({ userId => 3 });
|
||||
$response = WebGUI::Operation::User::www_ajaxDeleteUser( $session );
|
||||
is( $session->http->getMimeType, 'application/json', "Correct mime type (default: json)" );
|
||||
is( $session->response->content_type, 'application/json', "Correct mime type (default: json)" );
|
||||
cmp_deeply(
|
||||
JSON->new->decode( $response ),
|
||||
{
|
||||
|
|
@ -411,7 +411,7 @@ $session->request->setup_body({
|
|||
});
|
||||
$session->user({ userId => 3 });
|
||||
$response = WebGUI::Operation::User::www_ajaxDeleteUser( $session );
|
||||
is( $session->http->getMimeType, 'application/json', "Correct mime type (default: json)" );
|
||||
is( $session->response->content_type, 'application/json', "Correct mime type (default: json)" );
|
||||
cmp_deeply(
|
||||
JSON->new->decode( $response ),
|
||||
{
|
||||
|
|
@ -427,7 +427,7 @@ $session->request->setup_body({
|
|||
userId => $userAndy->getId,
|
||||
});
|
||||
$response = WebGUI::Operation::User::www_ajaxDeleteUser( $session );
|
||||
is( $session->http->getMimeType, 'application/json', 'Correct mime type (default: json)' );
|
||||
is( $session->response->content_type, 'application/json', 'Correct mime type (default: json)' );
|
||||
cmp_deeply(
|
||||
JSON->new->decode( $response ),
|
||||
{
|
||||
|
|
@ -441,7 +441,7 @@ $session->request->setup_body({
|
|||
userId => $userRed->getId,
|
||||
});
|
||||
$response = WebGUI::Operation::User::www_ajaxDeleteUser( $session );
|
||||
is( $session->http->getMimeType, 'application/json', 'Correct mime type (default: json)' );
|
||||
is( $session->response->content_type, 'application/json', 'Correct mime type (default: json)' );
|
||||
cmp_deeply(
|
||||
JSON->new->decode( $response ),
|
||||
{
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ use Data::Dumper;
|
|||
use Test::More; # increment this value for each test you create
|
||||
use Test::Deep;
|
||||
|
||||
plan tests => 46;
|
||||
plan tests => 44;
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
|
|
@ -55,19 +55,6 @@ $response->status('302');
|
|||
ok($http->isRedirect, '... 302 is too');
|
||||
$response->status('200');
|
||||
|
||||
####################################################
|
||||
#
|
||||
# setMimeType, getMimeType
|
||||
#
|
||||
####################################################
|
||||
|
||||
$http->setMimeType('');
|
||||
is($http->getMimeType, 'text/html; charset=UTF-8', 'set/get MimeType: default is text/html');
|
||||
|
||||
$http->setMimeType('image/jpeg');
|
||||
is($http->getMimeType, 'image/jpeg', 'set/get MimeType: set specific type and get it');
|
||||
$http->setMimeType('');
|
||||
|
||||
####################################################
|
||||
#
|
||||
# setStreamedFile, getStreamedFile
|
||||
|
|
@ -91,13 +78,13 @@ $http->setStreamedFile('');
|
|||
|
||||
$http->setFilename('foo.bin');
|
||||
is($http->getFilename, 'foo.bin', 'set/get Filename: filename passed');
|
||||
is($http->getMimeType(), 'application/octet-stream', 'set/get Filename: default mime type is octet/stream');
|
||||
is($response->content_type(), 'application/octet-stream', 'set/get Filename: default mime type is octet/stream');
|
||||
|
||||
$http->setFilename('foo.txt','text/plain');
|
||||
is($http->getFilename, 'foo.txt', 'set/get Filename: filename set');
|
||||
is($http->getMimeType(), 'text/plain', 'set/get Filename: mime type set');
|
||||
is($response->content_type(), 'text/plain', 'set/get Filename: mime type set');
|
||||
$http->setFilename('');
|
||||
$http->setMimeType('');
|
||||
$response->content_type('');
|
||||
|
||||
####################################################
|
||||
#
|
||||
|
|
@ -201,6 +188,7 @@ is($http->sendHeader, undef, 'sendHeader returns undef when no request object is
|
|||
headers_out($session1->response->headers),
|
||||
{
|
||||
'Location' => '/here/there',
|
||||
'Content-Type' => 'text/html; charset=UTF-8',
|
||||
},
|
||||
'... location set'
|
||||
);
|
||||
|
|
@ -220,7 +208,6 @@ is($http->sendHeader, undef, 'sendHeader returns undef when no request object is
|
|||
my $http = $session->http;
|
||||
my $response = $session->response;
|
||||
$response->status(200);
|
||||
$http->setMimeType('');
|
||||
$session->request->protocol('');
|
||||
$http->setLastModified(1200);
|
||||
|
||||
|
|
@ -255,7 +242,7 @@ is($http->sendHeader, undef, 'sendHeader returns undef when no request object is
|
|||
my $http = $session->http;
|
||||
my $response = $session->response;
|
||||
$http->setFilename('image.png');
|
||||
$http->setMimeType('image/png');
|
||||
$response->content_type('image/png');
|
||||
$http->sendHeader();
|
||||
is($response->headers->content_type, 'image/png', 'sendHeader: mimetype');
|
||||
cmp_deeply(
|
||||
|
|
|
|||
|
|
@ -52,11 +52,11 @@ like($response->body->[-1], qr/3\Z/, '... macro processing');
|
|||
$output->print('^#;', 1);
|
||||
like($response->body->[-1], qr/\^#;\Z/, '... macro processing skipped due to flag');
|
||||
|
||||
$session->http->setMimeType('application/json');
|
||||
$session->response->content_type('application/json');
|
||||
$output->print('^#;');
|
||||
like($response->body->[-1], qr/\^#;\Z/, '... macro processing skipped due to mime type');
|
||||
|
||||
$session->http->setMimeType('');
|
||||
$session->response->content_type('');
|
||||
$output->setHandle($otherHandle);
|
||||
$output->print('New content');
|
||||
is($otherHandleBuffer, 'New content', '... set to explicit handle');
|
||||
|
|
|
|||
|
|
@ -596,7 +596,7 @@ is($taxer->getTaxRate( $taxableDonation, $taxFreeAddress ), 0, 'calculate: simpl
|
|||
$session->user({userId=>3});
|
||||
my $json = $taxer->www_getTaxesAsJson();
|
||||
ok($json, 'www_getTaxesAsJson returned something');
|
||||
is($session->http->getMimeType, 'application/json', 'MIME type set to application/json');
|
||||
is($session->response->content_type, 'application/json', 'MIME type set to application/json');
|
||||
my $jsonTax = JSON::from_json($json);
|
||||
cmp_deeply(
|
||||
$jsonTax,
|
||||
|
|
|
|||
|
|
@ -191,7 +191,7 @@ is(scalar @{$transaction->getItems}, 0, "can delete items");
|
|||
$session->user({userId=>3});
|
||||
my $json = WebGUI::Shop::Transaction->www_getTransactionsAsJson($session);
|
||||
ok($json, 'www_getTransactionsAsJson returned something');
|
||||
is($session->http->getMimeType, 'application/json', 'MIME type set to application/json');
|
||||
is($session->response->content_type, 'application/json', 'MIME type set to application/json');
|
||||
my $jsonTransactions = JSON::from_json($json);
|
||||
cmp_deeply(
|
||||
$jsonTransactions,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue