title: How do I set the User-Agent header when making a request with Hyper?
body: <p>I'm trying to do a GET request to Github's API in Rust with the Hyper library, and with a user-agent string in the header. I haven't had luck compiling with <code>.header(UserAgent("string"))</code>. Would anyone be willing to propose an idiomatic way to accomplish what I want?</p>
  
  <pre><code>extern crate hyper;
  
  use std::io::Read;
  
  use hyper::Client;
  use hyper::header::{Connection, Headers};
  
  struct Subtasks {
      github: &amp;'static str,
  }
  
  struct Tasks {
      rust: Subtasks,
      go:   Subtasks,
  }
  
  fn main() {
      // initialize struct and populate
      let tasks = Tasks {
          rust: Subtasks {
              github: "https://api.github.com/rust-lang/rust",
          },
          go: Subtasks {
              github: "https://api.github.com/golang/go",
          },
      };
  
      let client = Client::new();
      let mut result = client.get(tasks.rust.github)
          .header(Connection::close())
          .send()
          .unwrap();
  
      let mut body = String::new();
      result.read_to_string(&amp;mut body).unwrap();
  
      println!("Response: {}", body);
  }
  </code></pre>