(data: HashMap<String, String>)
| 46 | } |
| 47 | |
| 48 | pub fn form_to_bytes(data: HashMap<String, String>) -> Vec<u8> { |
| 49 | let mut body = Vec::new(); |
| 50 | for (key, value) in data { |
| 51 | body.extend_from_slice(urlencoding::encode(key.as_str()).as_bytes()); |
| 52 | body.extend_from_slice("=".as_bytes()); |
| 53 | body.extend_from_slice(urlencoding::encode(value.as_str()).as_bytes()); |
| 54 | body.extend_from_slice("&".as_bytes()); |
| 55 | } |
| 56 | body.pop(); // Remove the last "&" |
| 57 | body |
| 58 | } |