tripod 0.9.2 → 0.9.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,4 @@
1
+ # -*- coding: utf-8 -*-
1
2
  require 'net/http'
2
3
 
3
4
  module Tripod
@@ -20,10 +21,11 @@ module Tripod
20
21
  http.read_timeout = timeout_in_seconds
21
22
 
22
23
  total_bytes = 0
23
- response_string = ""
24
24
 
25
25
  request_start_time = Time.now if Tripod.logger.debug?
26
26
 
27
+ response = StringIO.new
28
+
27
29
  begin
28
30
  http.request_post(uri.request_uri, payload, 'Accept' => accept) do |res|
29
31
 
@@ -34,18 +36,16 @@ module Tripod
34
36
 
35
37
  stream_start_time = Time.now if Tripod.logger.debug?
36
38
 
39
+ response.set_encoding('UTF-8')
37
40
  res.read_body do |seg|
38
- total_bytes += seg.size
39
- # FORCE ENCODING to utf 8
40
- response_string += seg.to_s.force_encoding('UTF-8')
41
- response_string = response_string.force_encoding('UTF-8')
42
- # raise Tripod::Errors::Timeout.new
43
- # if there's a limit, stop when we reach it
41
+ total_bytes += seg.bytesize
44
42
  raise Tripod::Errors::SparqlResponseTooLarge.new if limit_in_bytes && (total_bytes > limit_in_bytes)
43
+ response << seg
44
+ seg
45
45
  end
46
46
 
47
47
  if Tripod.logger.debug?
48
- stream_duration = Time.now - stream_start_time if
48
+ stream_duration = Time.now - stream_start_time
49
49
  total_request_time = Time.now - request_start_time
50
50
  end
51
51
 
@@ -56,9 +56,8 @@ module Tripod
56
56
  raise Tripod::Errors::Timeout.new
57
57
  end
58
58
 
59
- response_string
60
-
59
+ response.string
61
60
  end
62
61
 
63
62
  end
64
- end
63
+ end
@@ -1,3 +1,3 @@
1
1
  module Tripod
2
- VERSION = "0.9.2"
2
+ VERSION = "0.9.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tripod
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
4
+ version: 0.9.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2014-02-24 00:00:00.000000000 Z
14
+ date: 2014-03-18 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rest-client