(self, req)
| 1466 | |
| 1467 | # not entirely sure what the rules are here |
| 1468 | def open_local_file(self, req): |
| 1469 | import email.utils |
| 1470 | import mimetypes |
| 1471 | localfile = url2pathname(req.full_url, require_scheme=True, resolve_host=True) |
| 1472 | try: |
| 1473 | stats = os.stat(localfile) |
| 1474 | size = stats.st_size |
| 1475 | modified = email.utils.formatdate(stats.st_mtime, usegmt=True) |
| 1476 | mtype = mimetypes.guess_file_type(localfile)[0] |
| 1477 | headers = email.message_from_string( |
| 1478 | 'Content-type: %s\nContent-length: %d\nLast-modified: %s\n' % |
| 1479 | (mtype or 'text/plain', size, modified)) |
| 1480 | origurl = pathname2url(localfile, add_scheme=True) |
| 1481 | return addinfourl(open(localfile, 'rb'), headers, origurl) |
| 1482 | except OSError as exp: |
| 1483 | raise URLError(exp, exp.filename) |
| 1484 | |
| 1485 | file_open = open_local_file |
| 1486 |
nothing calls this directly
no test coverage detected