[LON-CAPA-cvs] cvs: loncom /cgi plot.gif
musolffc
musolffc at source.lon-capa.org
Fri Aug 19 01:15:21 EDT 2016
musolffc Fri Aug 19 05:15:21 2016 EDT
Modified files:
/loncom/cgi plot.gif
Log:
Sending "Content-length" when dynamically generating images
Now calculating and sending Content-length in the header for dynamically
generated images.
There was an issue where such images were intermittently not displaying in
Google Chrome. This seems to have fixed that problem.
Index: loncom/cgi/plot.gif
diff -u loncom/cgi/plot.gif:1.14 loncom/cgi/plot.gif:1.15
--- loncom/cgi/plot.gif:1.14 Wed Aug 14 00:38:55 2013
+++ loncom/cgi/plot.gif Fri Aug 19 05:15:21 2016
@@ -1,6 +1,6 @@
#!/usr/bin/perl
#
-# $Id: plot.gif,v 1.14 2013/08/14 00:38:55 raeburn Exp $
+# $Id: plot.gif,v 1.15 2016/08/19 05:15:21 musolffc Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -25,6 +25,7 @@
# http://www.lon-capa.org/
#
use strict;
+use bytes;
$|=1;
@@ -48,14 +49,17 @@
if ($output eq 'gif' || $output eq 'png') {
open(my $plot, "gnuplot $filename |");
-
+ my $image_content= '';
+ while (my $line = <$plot>) {
+ $image_content .= $line;
+ }
+ my $length = bytes::length($image_content);
print <<"END";
Content-type: image/$output
+Content-length: $length
+$image_content
END
- while (my $line = <$plot>) {
- print($line);
- }
} elsif ($output eq 'eps') {
print <<"END";
More information about the LON-CAPA-cvs
mailing list