MCPcopy Index your code
hub / github.com/RustPython/RustPython / set_server_hostname

Method set_server_hostname

crates/stdlib/src/ssl.rs:3895–3917  ·  view source on GitHub ↗
(
            &self,
            value: Option<PyUtf8StrRef>,
            vm: &VirtualMachine,
        )

Source from the content-addressed store, hash-verified

3893
3894 #[pygetset(setter)]
3895 fn set_server_hostname(
3896 &self,
3897 value: Option<PyUtf8StrRef>,
3898 vm: &VirtualMachine,
3899 ) -> PyResult<()> {
3900 // Check if handshake is already done
3901 if *self.handshake_done.lock() {
3902 return Err(
3903 vm.new_value_error("Cannot set server_hostname on socket after handshake")
3904 );
3905 }
3906
3907 // Validate hostname
3908 let hostname_string = value
3909 .map(|s| {
3910 validate_hostname(s.as_str(), vm)?;
3911 Ok::<String, _>(s.as_str().to_owned())
3912 })
3913 .transpose()?;
3914
3915 *self.server_hostname.write() = hostname_string;
3916 Ok(())
3917 }
3918
3919 #[pygetset]
3920 fn session(&self, vm: &VirtualMachine) -> PyResult<PyObjectRef> {

Callers

nothing calls this directly

Calls 7

validate_hostnameFunction · 0.85
ErrClass · 0.50
lockMethod · 0.45
mapMethod · 0.45
as_strMethod · 0.45
to_ownedMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected