swish/commit

Updated up stream files.

authorJan Wielemaker
Thu Apr 25 13:44:55 2019 +0200
committerJan Wielemaker
Thu Apr 25 13:44:55 2019 +0200
commit6e8472ff2bf45cd29a1ccfd3a7ea9956abd376b4
tree32e98b502d7feb58b2e84427c16a0b75cef01811
parentea22467a48cf28ae1c5825ef5842333814d2d2e8
Diff style: patch stat
diff --git a/lib/swish/chatstore.pl b/lib/swish/chatstore.pl
index 379cd93..b737bea 100644
--- a/lib/swish/chatstore.pl
+++ b/lib/swish/chatstore.pl
@@ -185,8 +185,12 @@ read_messages(File, Messages, Options) :-
 read_messages_from_stream(In, Messages, Options) :-
     option(max(Max), Options, 25),
     integer(Max),
-    seek(In, 0, eof, _Pos),
-    backskip_lines(In, Max),
+    setup_call_cleanup(
+        set_stream(In, encoding(octet)),
+        (   seek(In, 0, eof, _Pos),
+            backskip_lines(In, Max)
+        ),
+        set_stream(In, encoding(utf8))),
     !,
     read_terms(In, Messages).
 read_messages_from_stream(In, Messages, _Options) :-
diff --git a/lib/swish/swish_csv.pl b/lib/swish/swish_csv.pl
index a2db2c9..9fb649b 100644
--- a/lib/swish/swish_csv.pl
+++ b/lib/swish/swish_csv.pl
@@ -39,6 +39,7 @@
 :- use_module(library(apply)).
 :- use_module(library(pprint)).
 :- use_module(library(option)).
+:- use_module(library(http/http_cors)).
 
 /** <module> Support CSV output from a Pengines server
 
@@ -105,6 +106,7 @@ success(Answers, _VarTerm, Options) :-
 success(Answers, VarTerm, Options) :-
 	option(disposition(Disposition), Options, 'swish-result.csv'),
 	maplist(csv_answer, Answers, Rows),
+	cors_enable,
 	format('Content-encoding: chunked~n'),
 	format('Content-disposition: attachment; filename="~w"~n', [Disposition]),
 	format('Content-type: text/csv~n~n'),