MCPcopy Index your code
hub / github.com/cipheras/cipherginx / do_GET

Method do_GET

cipherginx.py:172–212  ·  view source on GitHub ↗
(self, body=True)

Source from the content-addressed store, hash-verified

170 self.do_GET(body=False)
171
172 def do_GET(self, body=True):
173 sent = False
174 try:
175 logging.info('path::' + self.path)
176 if blockPaths(self.path): return
177 hn = hostname
178 for _ in req_headers:
179 if _[0] in self.path:
180 for k,v in _[1].items():
181 if k=='Host': hn=v
182 url = 'https://' + hn + self.path.replace(domain,hostname.split('.',1)[1])
183 # Parse request
184 print('\n//'+self.command)
185 print(LIGHTGREEN + url + RESET)
186 req_header = self.parseHeaders()
187 # Call the target hostname
188 resp = self.s.get(url, headers=injectHeaders(req_header, url, self.headers['Content-Length'], self.path), verify=False, allow_redirects=True,)
189 sent = True
190 if resp.history:
191 for r in resp.history:
192 print('Redirection: '+BOLD+CYAN+'[',r.status_code,'] ',r.url, RESET)
193 # Respond with the requested data
194 self.sendRespHeaders(resp)
195 if body:
196 inj_resp = injectRespBody(resp.content, self.path)
197 self.send_header('Content-Length', len(inj_resp))
198 self.end_headers()
199 self.wfile.write(inj_resp)
200 else:
201 self.send_header('Content-Length', len(resp.content))
202 self.end_headers()
203 return
204 except Exception as e:
205 logging.error(RED + str(e))
206 logging.debug(e, exc_info=True)
207 # exit()
208 finally:
209 # self.finish()
210 if not sent:
211 self.send_error(200, 'No Content')
212 logging.info('sending [200] with no content to target')
213
214 def do_POST(self, body=True):
215 sent = False

Callers 1

do_HEADMethod · 0.95

Calls 5

parseHeadersMethod · 0.95
sendRespHeadersMethod · 0.95
blockPathsFunction · 0.85
injectHeadersFunction · 0.85
injectRespBodyFunction · 0.85

Tested by

no test coverage detected