| 138 | |
| 139 | @property |
| 140 | def headers(self): |
| 141 | url = urlsplit(self._orig.url) |
| 142 | |
| 143 | request_line = '{method} {path}{query} HTTP/1.1'.format( |
| 144 | method=self._orig.method, |
| 145 | path=url.path or '/', |
| 146 | query=f'?{url.query}' if url.query else '' |
| 147 | ) |
| 148 | |
| 149 | headers = self._orig.headers.copy() |
| 150 | if 'Host' not in self._orig.headers: |
| 151 | headers['Host'] = url.netloc.split('@')[-1] |
| 152 | |
| 153 | headers = [ |
| 154 | f'{name}: {value if isinstance(value, str) else value.decode()}' |
| 155 | for name, value in headers.items() |
| 156 | if not (name.lower() in SKIPPABLE_HEADERS and value == SKIP_HEADER) |
| 157 | ] |
| 158 | |
| 159 | headers.insert(0, request_line) |
| 160 | headers = '\r\n'.join(headers).strip() |
| 161 | return headers |
| 162 | |
| 163 | @property |
| 164 | def body(self): |