Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

…m http_client
  • Loading branch information...
commit 966aba2e571f68a22bd90f8a88c183d754291e6d 1 parent 9bc0335
Jonathan Roes authored
Showing with 22 additions and 25 deletions.
  1. +0 −2  src/http_client.coffee
  2. +22 −23 src/http_meta.coffee
View
2  src/http_client.coffee
@@ -226,8 +226,6 @@ class HttpClient extends Client
meta.headers = meta.toHeaders()
Client.debug "#{meta.method} #{meta.path}", meta
- meta.headers['Connection'] = 'keep-alive'
-
request = @_http.request meta, (response) =>
# using meta as options, to which the HTTP Agent is attached
View
45 src/http_meta.coffee
@@ -5,7 +5,7 @@ class Meta extends CoreMeta
load: (options) ->
super options, Meta.riakProperties.concat(Meta.queryProperties), Meta.defaults, CoreMeta.defaults
-
+
# HTTP response header mappings
responseMappings:
@@ -22,10 +22,10 @@ class Meta extends CoreMeta
loadResponse: (response) ->
headers = response.headers
-
+
# one-to-one
for v,k of @responseMappings then this[k] = headers[v]
-
+
# status code
@statusCode = response.statusCode
@@ -33,20 +33,20 @@ class Meta extends CoreMeta
for k,v of headers
u = k.match /^X-Riak-Meta-(.*)/i
@usermeta[u[1]] = v if u
-
+
# links
if headers.link then @links = linkUtils.stringToLinks headers.link
-
+
# etag -- replace any quotes in the string
if headers.etag then @etag = headers.etag.replace /"/g, ''
-
+
# location
if headers.location
[$0, @raw, @bucket, @key] = headers.location.match /^\/([^\/]+)(?:\/([^\/]+))?\/([^\/]+)$/
-
+
# delete method used in previous request
delete @method
-
+
return this
# HTTP request header mappings
@@ -64,14 +64,14 @@ class Meta extends CoreMeta
# other request info:
# usermeta (X-Riak-Meta-*), links, contentType
# ignored info: binary, raw, url, path
-
+
toHeaders: ->
-
+
headers = {}
-
+
# remove client id if there's no vclock
delete @requestMappings.clientId unless this.vclock?
-
+
for k,v of @requestMappings then headers[v] = this[k] if this[k]
# 2i
@@ -81,27 +81,27 @@ class Meta extends CoreMeta
# usermeta
for k,v of @usermeta then headers["X-Riak-Meta-#{k}"] = String(v)
-
+
# links
headers['Link'] = linkUtils.linksToString(@links, @raw) if @links.length > 0
-
+
if @data?
-
+
# now we need to encode the data to calculate its type and length
@encodeData()
-
+
# contentType
headers['Content-Type'] = @contentType
-
+
# don't send chunked data at least until riak #278 gets fixed or we can stream the req body
headers['Content-Length'] = @data.length
-
+
if @headers
for k of @headers then headers[k] = @headers[k]
delete @headers
-
+
return headers
-
+
doEncodeUri: (component = '') ->
if @encodeUri
encodeURIComponent component.replace /\+/g, "%20"
@@ -119,13 +119,12 @@ Meta::__defineGetter__ 'queryProps', ->
queryProps = {}
Meta.queryProperties.forEach (prop) => queryProps[prop] = this[prop] if this[prop]?
queryProps
-
+
Meta.defaults =
host: 'localhost'
port: 8098
accept: 'multipart/mixed, application/json;q=0.7, */*;q=0.5'
responseEncoding: 'utf8'
- connection: 'close' # should be keep-alive, but getting a lot of weird errors in tests
Meta.queryProperties = [
'r'
@@ -164,6 +163,6 @@ linkUtils =
for i of captures then captures[i] = decodeURIComponent(captures[i])
result.push { bucket: captures[2], key: captures[3], tag: captures[4] }
result
-
+
linksToString: (links, raw) ->
links.map((link) => "</#{raw}/#{encodeURIComponent link.bucket}/#{encodeURIComponent link.key}>; riaktag=\"#{encodeURIComponent link.tag || "_"}\"").join ", "
Please sign in to comment.
Something went wrong with that request. Please try again.