137 if pycompat.ispy3: |
137 if pycompat.ispy3: |
138 if self.headers.get_content_type() is None: |
138 if self.headers.get_content_type() is None: |
139 env[r'CONTENT_TYPE'] = self.headers.get_default_type() |
139 env[r'CONTENT_TYPE'] = self.headers.get_default_type() |
140 else: |
140 else: |
141 env[r'CONTENT_TYPE'] = self.headers.get_content_type() |
141 env[r'CONTENT_TYPE'] = self.headers.get_content_type() |
142 length = self.headers.get('content-length') |
142 length = self.headers.get(r'content-length') |
143 else: |
143 else: |
144 if self.headers.typeheader is None: |
144 if self.headers.typeheader is None: |
145 env[r'CONTENT_TYPE'] = self.headers.type |
145 env[r'CONTENT_TYPE'] = self.headers.type |
146 else: |
146 else: |
147 env[r'CONTENT_TYPE'] = self.headers.typeheader |
147 env[r'CONTENT_TYPE'] = self.headers.typeheader |
148 length = self.headers.getheader('content-length') |
148 length = self.headers.getheader(r'content-length') |
149 if length: |
149 if length: |
150 env[r'CONTENT_LENGTH'] = length |
150 env[r'CONTENT_LENGTH'] = length |
151 for header in [h for h in self.headers.keys() |
151 for header in [h for h in self.headers.keys() |
152 if h not in ('content-type', 'content-length')]: |
152 if h not in (r'content-type', r'content-length')]: |
153 hkey = r'HTTP_' + header.replace(r'-', r'_').upper() |
153 hkey = r'HTTP_' + header.replace(r'-', r'_').upper() |
154 hval = self.headers.get(header) |
154 hval = self.headers.get(header) |
155 hval = hval.replace(r'\n', r'').strip() |
155 hval = hval.replace(r'\n', r'').strip() |
156 if hval: |
156 if hval: |
157 env[hkey] = hval |
157 env[hkey] = hval |