Skip to content

Commit 76c8c66

Browse files
Andreas Eichnertbonfort
Andreas Eichner
authored andcommitted
jsonp support
1 parent f79aacc commit 76c8c66

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

mapfile.c

+1
Original file line numberDiff line numberDiff line change
@@ -6856,6 +6856,7 @@ void msApplyDefaultSubstitutions(mapObj *map)
68566856
/* output formats (#3751) */
68576857
for(i=0; i<map->numoutputformats; i++) {
68586858
applyOutputFormatDefaultSubstitutions(map->outputformatlist[i], "filename", &(map->web.validation));
6859+
applyOutputFormatDefaultSubstitutions(map->outputformatlist[i], "JSONP", &(map->web.validation));
68596860
}
68606861

68616862
for(i=0; i<map->numlayers; i++) {

mapogroutput.c

+7
Original file line numberDiff line numberDiff line change
@@ -1153,8 +1153,11 @@ int msOGRWriteFromQuery( mapObj *map, outputFormatObj *format, int sendheaders )
11531153
char buffer[1024];
11541154
int bytes_read;
11551155
FILE *fp;
1156+
const char *jsonp;
11561157

1158+
jsonp = msGetOutputFormatOption( format, "JSONP", NULL );
11571159
if( sendheaders ) {
1160+
if( !jsonp )
11581161
msIO_setHeader("Content-Disposition","attachment; filename=%s",
11591162
CPLGetFilename( file_list[0] ) );
11601163
if( format->mimetype )
@@ -1173,9 +1176,13 @@ int msOGRWriteFromQuery( mapObj *map, outputFormatObj *format, int sendheaders )
11731176
return MS_FAILURE;
11741177
}
11751178

1179+
if( jsonp != NULL ) msIO_fprintf( stdout, "%s(", jsonp );
1180+
11761181
while( (bytes_read = VSIFReadL( buffer, 1, sizeof(buffer), fp )) > 0 )
11771182
msIO_fwrite( buffer, 1, bytes_read, stdout );
11781183
VSIFCloseL( fp );
1184+
1185+
if (jsonp != NULL) msIO_fprintf( stdout, ");\n" );
11791186
}
11801187

11811188
/* -------------------------------------------------------------------- */

0 commit comments

Comments
 (0)