[Groonga-commit] groonga/grntest at 3ee8f0e [master] Support JSONP

Back to archive index

Kouhei Sutou null+****@clear*****
Sat Mar 28 13:58:29 JST 2015


Kouhei Sutou	2015-03-28 13:58:29 +0900 (Sat, 28 Mar 2015)

  New Revision: 3ee8f0e5ab78ecb57156a6cc289fb75c5bfc88be
  https://github.com/groonga/grntest/commit/3ee8f0e5ab78ecb57156a6cc289fb75c5bfc88be

  Message:
    Support JSONP

  Modified files:
    lib/grntest/test-runner.rb

  Modified: lib/grntest/test-runner.rb (+16 -2)
===================================================================
--- lib/grntest/test-runner.rb    2015-03-12 15:56:10 +0900 (aab9628)
+++ lib/grntest/test-runner.rb    2015-03-28 13:58:29 +0900 (5cbb431)
@@ -501,8 +501,17 @@ http {
       when "json", "msgpack"
         status = nil
         values = nil
+        content = content.chomp
+        if type == "json" and /\A([^(]+\()(.+)(\);)\z/ =~ content
+          jsonp = true
+          jsonp_start = $1
+          content = $2
+          jsonp_end = $3
+        else
+          jsonp = false
+        end
         begin
-          status, *values = ResponseParser.parse(content.chomp, type)
+          status, *values = ResponseParser.parse(content, type)
         rescue ParseError
           return $!.message
         end
@@ -513,7 +522,12 @@ http {
         if normalized_output.bytesize > @max_n_columns
           normalized_output = JSON.pretty_generate(normalized_output_content)
         end
-        normalize_raw_content(normalized_output)
+        normalized_raw_content = normalize_raw_content(normalized_output)
+        if jsonp
+          jsonp_start + normalized_raw_content + jsonp_end
+        else
+          normalized_raw_content
+        end
       when "xml"
         normalized_xml = normalize_output_xml(content, options)
         normalize_raw_content(normalized_xml)
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index