tcp - Make HTTP Request in Rust using std -


I'm trying to teach myself Rust I know about it, but I want to make my own http client I am currently building for GNU Linux 64bit.

This is my current code:

  use std :: io :: net :: ip :: SocketAddr; Use std :: io :: net :: tcp :: TcpStream; Use std :: io :: net :: addrinfo :: get_host_addresses; Use std :: io :: net :: ip :: IpAddr; Use std :: io :: stdio :: println; Fn Main () {// http end point hosts = ~ "www.telize.com"; Path = ~ "/ goip"; // Try changing host to IP address ip_lookup = get_host_addresses (host) .unwrap (); // Open socket connection addr = SocketAddr {ip: ip_lookup [0] .clone (), port: port.clone ()}; Repeat socket = TCPstream :: connect_time (ADR, 200U64). Unwop (); // format HTTP request mute header = format! ("GET {} http / 1.0 \ r \ nHost: {} \ r \ n", path.clone (), host.clone ()); Println (header); Socket.write_str (header); // Requesting and returning the response as strings resp = socket.read_to_str (). Unwrap (); Println (resp); }  

It collects, however, to see the code I see the HTTP request on the socket, but then it is hanging in the terminal. Also, there is no answer Testing this URL in the browser gives a JSON response. How can I get this feedback (or any response) by using the Jung Stud library? Thanks!

Your request is bad, in which you have not concluded the header, and therefore it is waiting for you To do this, you need a blank line to end the header.

(BTW, I have not defined ports ).

/ html>

Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -