blob: b70502ce05b3c6049a699b23456bd7ab1b64693a [file] [log] [blame]
Mate Lakat23a58a32013-08-23 02:06:22 +01001# vim: tabstop=4 shiftwidth=4 softtabstop=4
2
ZhiQiang Fan39f97222013-09-20 04:49:44 +08003# Copyright 2013 OpenStack Foundation
Mate Lakat23a58a32013-08-23 02:06:22 +01004# Copyright 2013 Citrix Systems, Inc.
5# All Rights Reserved.
6#
7# Licensed under the Apache License, Version 2.0 (the "License"); you may
8# not use this file except in compliance with the License. You may obtain
9# a copy of the License at
10#
11# http://www.apache.org/licenses/LICENSE-2.0
12#
13# Unless required by applicable law or agreed to in writing, software
14# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16# License for the specific language governing permissions and limitations
17# under the License.
18
19import httplib2
20
21
22class ClosingHttp(httplib2.Http):
23 def request(self, *args, **kwargs):
24 original_headers = kwargs.get('headers', {})
25 new_headers = dict(original_headers, connection='close')
26 new_kwargs = dict(kwargs, headers=new_headers)
27 return super(ClosingHttp, self).request(*args, **new_kwargs)