Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

remove connection close header from http_meta and keep-alive hack fro…

…m http_client
  • Loading branch information...
commit 966aba2e571f68a22bd90f8a88c183d754291e6d 1 parent 9bc0335
authored
2  src/http_client.coffee
@@ -226,8 +226,6 @@ class HttpClient extends Client
226 226
     meta.headers = meta.toHeaders()
227 227
     Client.debug "#{meta.method} #{meta.path}", meta
228 228
 
229  
-    meta.headers['Connection'] = 'keep-alive'
230  
-
231 229
     request = @_http.request meta, (response) =>
232 230
 
233 231
       # using meta as options, to which the HTTP Agent is attached
45  src/http_meta.coffee
@@ -5,7 +5,7 @@ class Meta extends CoreMeta
5 5
 
6 6
   load: (options) ->
7 7
     super options, Meta.riakProperties.concat(Meta.queryProperties), Meta.defaults, CoreMeta.defaults
8  
-      
  8
+
9 9
   # HTTP response header mappings
10 10
 
11 11
   responseMappings:
@@ -22,10 +22,10 @@ class Meta extends CoreMeta
22 22
 
23 23
   loadResponse: (response) ->
24 24
     headers = response.headers
25  
-    
  25
+
26 26
     # one-to-one
27 27
     for v,k of @responseMappings then this[k] = headers[v]
28  
-    
  28
+
29 29
     # status code
30 30
     @statusCode = response.statusCode
31 31
 
@@ -33,20 +33,20 @@ class Meta extends CoreMeta
33 33
     for k,v of headers
34 34
       u = k.match /^X-Riak-Meta-(.*)/i
35 35
       @usermeta[u[1]] = v if u
36  
-    
  36
+
37 37
     # links
38 38
     if headers.link then @links = linkUtils.stringToLinks headers.link
39  
-    
  39
+
40 40
     # etag -- replace any quotes in the string
41 41
     if headers.etag then @etag = headers.etag.replace /"/g, ''
42  
-    
  42
+
43 43
     # location
44 44
     if headers.location
45 45
       [$0, @raw, @bucket, @key] = headers.location.match /^\/([^\/]+)(?:\/([^\/]+))?\/([^\/]+)$/
46  
-    
  46
+
47 47
     # delete method used in previous request
48 48
     delete @method
49  
-    
  49
+
50 50
     return this
51 51
 
52 52
   # HTTP request header mappings
@@ -64,14 +64,14 @@ class Meta extends CoreMeta
64 64
     # other request info:
65 65
     # usermeta (X-Riak-Meta-*), links, contentType
66 66
     # ignored info: binary, raw, url, path
67  
-    
  67
+
68 68
   toHeaders: ->
69  
-    
  69
+
70 70
     headers = {}
71  
-  
  71
+
72 72
     # remove client id if there's no vclock
73 73
     delete @requestMappings.clientId unless this.vclock?
74  
-  
  74
+
75 75
     for k,v of @requestMappings then headers[v] = this[k] if this[k]
76 76
 
77 77
     # 2i
@@ -81,27 +81,27 @@ class Meta extends CoreMeta
81 81
 
82 82
     # usermeta
83 83
     for k,v of @usermeta then headers["X-Riak-Meta-#{k}"] = String(v)
84  
-  
  84
+
85 85
     # links
86 86
     headers['Link'] = linkUtils.linksToString(@links, @raw) if @links.length > 0
87  
-    
  87
+
88 88
     if @data?
89  
-    
  89
+
90 90
       # now we need to encode the data to calculate its type and length
91 91
       @encodeData()
92  
-    
  92
+
93 93
       # contentType
94 94
       headers['Content-Type'] = @contentType
95  
-    
  95
+
96 96
       # don't send chunked data at least until riak #278 gets fixed or we can stream the req body
97 97
       headers['Content-Length'] = @data.length
98  
-    
  98
+
99 99
     if @headers
100 100
       for k of @headers then headers[k] = @headers[k]
101 101
       delete @headers
102  
-    
  102
+
103 103
     return headers
104  
-    
  104
+
105 105
   doEncodeUri: (component = '') ->
106 106
     if @encodeUri
107 107
       encodeURIComponent component.replace /\+/g, "%20"
@@ -119,13 +119,12 @@ Meta::__defineGetter__ 'queryProps', ->
119 119
   queryProps = {}
120 120
   Meta.queryProperties.forEach (prop) => queryProps[prop] = this[prop] if this[prop]?
121 121
   queryProps
122  
-  
  122
+
123 123
 Meta.defaults =
124 124
   host: 'localhost'
125 125
   port: 8098
126 126
   accept: 'multipart/mixed, application/json;q=0.7, */*;q=0.5'
127 127
   responseEncoding: 'utf8'
128  
-  connection: 'close' # should be keep-alive, but getting a lot of weird errors in tests
129 128
 
130 129
 Meta.queryProperties = [
131 130
   'r'
@@ -164,6 +163,6 @@ linkUtils =
164 163
           for i of captures then captures[i] = decodeURIComponent(captures[i])
165 164
           result.push { bucket: captures[2], key: captures[3], tag: captures[4] }
166 165
     result
167  
-    
  166
+
168 167
   linksToString: (links, raw) ->
169 168
     links.map((link) => "</#{raw}/#{encodeURIComponent link.bucket}/#{encodeURIComponent link.key}>; riaktag=\"#{encodeURIComponent link.tag || "_"}\"").join ", "

0 notes on commit 966aba2

Please sign in to comment.
Something went wrong with that request. Please try again.