MCPcopy Index your code
hub / github.com/webpy/webpy / __iter__

Method __iter__

web/httpserver.py:202–239  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

200 pass
201
202 def __iter__(self):
203 environ = self.environ
204
205 self.path = environ.get("PATH_INFO", "")
206 self.client_address = (
207 environ.get("REMOTE_ADDR", "-"),
208 environ.get("REMOTE_PORT", "-"),
209 )
210 self.command = environ.get("REQUEST_METHOD", "-")
211
212 self.wfile = BytesIO() # for capturing error
213
214 try:
215 path = self.translate_path(self.path)
216 etag = '"%s"' % os.path.getmtime(path)
217 client_etag = environ.get("HTTP_IF_NONE_MATCH")
218 self.send_header("ETag", etag)
219 if etag == client_etag:
220 self.send_response(304, "Not Modified")
221 self.start_response(self.status, self.headers)
222 return
223 except OSError:
224 pass # Probably a 404
225
226 f = self.send_head()
227 self.start_response(self.status, self.headers)
228
229 if f:
230 block_size = 16 * 1024
231 while True:
232 buf = f.read(block_size)
233 if not buf:
234 break
235 yield buf
236 f.close()
237 else:
238 value = self.wfile.getvalue()
239 yield value
240
241
242class StaticMiddleware:

Callers

nothing calls this directly

Calls 4

send_headerMethod · 0.95
send_responseMethod · 0.95
start_responseMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected