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
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue