Mate Lakat | 23a58a3 | 2013-08-23 02:06:22 +0100 | [diff] [blame] | 1 | # vim: tabstop=4 shiftwidth=4 softtabstop=4 |
| 2 | |
ZhiQiang Fan | 39f9722 | 2013-09-20 04:49:44 +0800 | [diff] [blame] | 3 | # Copyright 2013 OpenStack Foundation |
Mate Lakat | 23a58a3 | 2013-08-23 02:06:22 +0100 | [diff] [blame] | 4 | # 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 | |
| 19 | import httplib2 |
| 20 | |
| 21 | |
| 22 | class 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) |