Permalink
Browse files

jsonp support

  • Loading branch information...
Andreas Eichner authored and tbonfort committed Jan 15, 2015
1 parent f79aacc commit 76c8c66f7c3f27c626fd07013e415a43e7f0f904
Showing with 8 additions and 0 deletions.
  1. +1 −0 mapfile.c
  2. +7 −0 mapogroutput.c
View
@@ -6856,6 +6856,7 @@ void msApplyDefaultSubstitutions(mapObj *map)
/* output formats (#3751) */
for(i=0; i<map->numoutputformats; i++) {
applyOutputFormatDefaultSubstitutions(map->outputformatlist[i], "filename", &(map->web.validation));
applyOutputFormatDefaultSubstitutions(map->outputformatlist[i], "JSONP", &(map->web.validation));
}
for(i=0; i<map->numlayers; i++) {
View
@@ -1153,8 +1153,11 @@ int msOGRWriteFromQuery( mapObj *map, outputFormatObj *format, int sendheaders )
char buffer[1024];
int bytes_read;
FILE *fp;
const char *jsonp;
jsonp = msGetOutputFormatOption( format, "JSONP", NULL );
if( sendheaders ) {
if( !jsonp )
msIO_setHeader("Content-Disposition","attachment; filename=%s",
CPLGetFilename( file_list[0] ) );
if( format->mimetype )
@@ -1173,9 +1176,13 @@ int msOGRWriteFromQuery( mapObj *map, outputFormatObj *format, int sendheaders )
return MS_FAILURE;
}
if( jsonp != NULL ) msIO_fprintf( stdout, "%s(", jsonp );
while( (bytes_read = VSIFReadL( buffer, 1, sizeof(buffer), fp )) > 0 )
msIO_fwrite( buffer, 1, bytes_read, stdout );
VSIFCloseL( fp );
if (jsonp != NULL) msIO_fprintf( stdout, ");\n" );
}
/* -------------------------------------------------------------------- */

0 comments on commit 76c8c66

Please sign in to comment.