Helper to call socket methods, bypassing any SSL wrapper
(&self, size: usize, vm: &VirtualMachine)
| 2777 | |
| 2778 | // Helper to call socket methods, bypassing any SSL wrapper |
| 2779 | pub(crate) fn sock_recv(&self, size: usize, vm: &VirtualMachine) -> PyResult<PyObjectRef> { |
| 2780 | // In BIO mode, read from incoming BIO (flags not supported) |
| 2781 | if let Some(ref bio) = self.incoming_bio { |
| 2782 | let bio_obj: PyObjectRef = bio.clone().into(); |
| 2783 | let read_method = bio_obj.get_attr("read", vm)?; |
| 2784 | return read_method.call((vm.ctx.new_int(size),), vm); |
| 2785 | } |
| 2786 | |
| 2787 | // Normal socket mode |
| 2788 | let socket_mod = vm.import("socket", 0)?; |
| 2789 | let socket_class = socket_mod.get_attr("socket", vm)?; |
| 2790 | |
| 2791 | // Call socket.socket.recv(self.sock, size, flags) |
| 2792 | let recv_method = socket_class.get_attr("recv", vm)?; |
| 2793 | recv_method.call((self.sock.clone(), vm.ctx.new_int(size)), vm) |
| 2794 | } |
| 2795 | |
| 2796 | /// Peek at socket data without consuming it (MSG_PEEK). |
| 2797 | /// Used during TLS shutdown to avoid consuming post-TLS cleartext data. |
no test coverage detected