Merge "Fix 503 on zero-byte replicated PUT with incorrect Etag"
This commit is contained in:
commit
5a4cb95c71
@ -60,7 +60,8 @@ from swift.common.http import (
|
||||
is_informational, is_success, is_client_error, is_server_error,
|
||||
HTTP_CONTINUE, HTTP_CREATED, HTTP_MULTIPLE_CHOICES,
|
||||
HTTP_INTERNAL_SERVER_ERROR, HTTP_SERVICE_UNAVAILABLE,
|
||||
HTTP_INSUFFICIENT_STORAGE, HTTP_PRECONDITION_FAILED, HTTP_CONFLICT)
|
||||
HTTP_INSUFFICIENT_STORAGE, HTTP_PRECONDITION_FAILED, HTTP_CONFLICT,
|
||||
HTTP_UNPROCESSABLE_ENTITY)
|
||||
from swift.common.storage_policy import (POLICIES, REPL_POLICY, EC_POLICY,
|
||||
ECDriverError, PolicyError)
|
||||
from swift.proxy.controllers.base import Controller, delay_denial, \
|
||||
@ -893,7 +894,9 @@ class ReplicatedObjectController(BaseObjectController):
|
||||
conn.resp = None
|
||||
conn.node = node
|
||||
return conn
|
||||
elif is_success(resp.status) or resp.status == HTTP_CONFLICT:
|
||||
elif (is_success(resp.status)
|
||||
or resp.status in (HTTP_CONFLICT,
|
||||
HTTP_UNPROCESSABLE_ENTITY)):
|
||||
conn.resp = resp
|
||||
conn.node = node
|
||||
return conn
|
||||
|
@ -535,6 +535,22 @@ class TestReplicatedObjController(BaseObjectControllerMixin,
|
||||
resp = req.get_response(self.app)
|
||||
self.assertEqual(resp.status_int, 201)
|
||||
|
||||
def test_PUT_empty_bad_etag(self):
|
||||
req = swift.common.swob.Request.blank('/v1/a/c/o', method='PUT')
|
||||
req.headers['Content-Length'] = '0'
|
||||
req.headers['Etag'] = '"catbus"'
|
||||
|
||||
# The 2-tuple here makes getexpect() return 422, not 100. For
|
||||
# objects that are >0 bytes, you get a 100 Continue and then a 422
|
||||
# Unprocessable Entity after sending the body. For zero-byte
|
||||
# objects, though, you get the 422 right away.
|
||||
codes = [FakeStatus((422, 422))
|
||||
for _junk in range(self.replicas())]
|
||||
|
||||
with set_http_connect(*codes):
|
||||
resp = req.get_response(self.app)
|
||||
self.assertEqual(resp.status_int, 422)
|
||||
|
||||
def test_PUT_if_none_match(self):
|
||||
req = swift.common.swob.Request.blank('/v1/a/c/o', method='PUT')
|
||||
req.headers['if-none-match'] = '*'
|
||||
|
Loading…
x
Reference in New Issue
Block a user