HackerReposA FIELD GUIDE TO OPEN SOURCE
ProSponsor the shelf♧ 0
← Back to top all-time
chris-morgan
rust-http
Rust2013–2014
chris-morgan / rust-http · Archived

rust-http

Completely OBSOLETE Rust HTTP library (server and client)

8Distinct people
13Mentions
3Explicit recommenders
390GitHub stars
REPOSITORY AT A GLANCE

What to know before exploring

What it is

Completely OBSOLETE Rust HTTP library (server and client)

GitHub

Where it is used

No documented product use has been verified yet.

What people are saying

Since none of your examples are actually doing the same thing, I'm not sure what you're trying to say here. That being said, I've reformatted the code from the original post…

someone13 used a recommendation phrase. 3 indexed comments match. This is a phrase match, not a verdict.

No classified warning is attached to this page. Read the discussions before treating silence as approval.

Also in these discussions

No other repository is repeatedly linked in the same discussions.

This week on Hacker News

Nov 7–Nov 14 UTC · Direct repository links and separately labeled related project stories. Indexed through 11/14/2026, 1:49:46 PM UTC.

No direct repository links were found in the indexed HN discussions over the past seven days. Older discussions are available below.

Mentions over time

HN mentions by month13 dated mentions

Observed mentions: 2013-08-20 03:21:48 UTC to 2014-07-02 17:32:32 UTC.

01232013-08-01 00:00:00 UTC to 2013-09-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 commentsAug 20132013-09-01 00:00:00 UTC to 2013-10-01 00:00:00 UTC (exclusive): 3 mentions; 1 submissions, 2 comments2013-10-01 00:00:00 UTC to 2013-11-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2013-11-01 00:00:00 UTC to 2013-12-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2013-12-01 00:00:00 UTC to 2014-01-01 00:00:00 UTC (exclusive): 2 mentions; 0 submissions, 2 comments2014-01-01 00:00:00 UTC to 2014-02-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 commentsJan 20142014-02-01 00:00:00 UTC to 2014-03-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2014-03-01 00:00:00 UTC to 2014-04-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2014-04-01 00:00:00 UTC to 2014-05-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2014-05-01 00:00:00 UTC to 2014-06-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2014-06-01 00:00:00 UTC to 2014-07-01 00:00:00 UTC (exclusive): 2 mentions; 0 submissions, 2 comments2014-07-01 00:00:00 UTC to 2014-08-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 commentsJul 2014

Counts come from the repository’s dated source evidence. Index cutoff: 2026-11-02 08:16:59 UTC.

View mention counts and date ranges
UTC ranges include their start and exclude their end. Select a period to filter the source evidence.
PeriodStart (UTC)End (exclusive, UTC)MentionsSubmissionsComments
Aug 20132013-08-01 00:00:00 UTC2013-09-01 00:00:00 UTC101
Sep 20132013-09-01 00:00:00 UTC2013-10-01 00:00:00 UTC312
Oct 20132013-10-01 00:00:00 UTC2013-11-01 00:00:00 UTC101
Nov 20132013-11-01 00:00:00 UTC2013-12-01 00:00:00 UTC000
Dec 20132013-12-01 00:00:00 UTC2014-01-01 00:00:00 UTC202
Jan 20142014-01-01 00:00:00 UTC2014-02-01 00:00:00 UTC101
Feb 20142014-02-01 00:00:00 UTC2014-03-01 00:00:00 UTC101
Mar 20142014-03-01 00:00:00 UTC2014-04-01 00:00:00 UTC000
Apr 20142014-04-01 00:00:00 UTC2014-05-01 00:00:00 UTC101
May 20142014-05-01 00:00:00 UTC2014-06-01 00:00:00 UTC000
Jun 20142014-06-01 00:00:00 UTC2014-07-01 00:00:00 UTC202
Jul 20142014-07-01 00:00:00 UTC2014-08-01 00:00:00 UTC101

What Hacker News says

13 sources
I suspect the issue is Iron, though rust-http certainly isn't helping much. Here are some graphs, generated from data made by rust-http's benchmarking script (https://github.com/chris-morgan/rust-http/tree/master/compar...), on my box. A spreadsheet: https://docs.google.com/spreadsheets/d/1-5_4wPPKNBYZ6yuw-rRl... The raw data: https://gist.github.com/cmr/3648bcc6365c1dba83f1 The charts themselves: http://imgur.com/gw1mp40,Hn3929i,h2OQiTh Software versions: rustc 0.11.0-pre (44ec28cfac9fa3f738e0e77ccca1d804125fd1dd 2014-07-01 21:26:33 +0000) go version go1.3 linux/amd64 node v0.10.29 Apache 2.4.9 wrk 3.1.0 Arch Linux, x86_64, CPU: https://gist.github.com/cmr/7cc6df806caff2253667
In Show HN: Iron, a fast middleware-oriented Rust web server framework
someone13·Jun 29, 2014Recommendation phrase
Since none of your examples are actually doing the same thing, I'm not sure what you're trying to say here. That being said, I've reformatted the code from the original post below (presented without comment): ----- Haskell (with third party library) http://snapframework.com/docs/tutorials/snap-api main :: IO () main = quickHttpServe site site :: Snap () site = ifTop (writeBS "hello world") <|> route [ ("foo", writeBS "bar") , ("echo/:echoparam", echoHandler) ] <|> dir "static" (serveDirectory ".") echoHandler :: Snap () echoHandler = do param <- getParam "echoparam" maybe (writeBS "must specify echo/param in URL") writeBS param Rust (with third party library) https://github.com/chris-morgan/rust-http/blob/master/src/ex...
Read the rest
//! A very simple HTTP server which responds with the plain text "Hello, World!" to every request. #![crate_id = "hello_world"] extern crate time; extern crate http; use std::io::net::ip::{SocketAddr, Ipv4Addr}; use std::io::Writer; use http::server::{Config, Server, Request, ResponseWriter}; use http::headers::content_type::MediaType; #[deriving(Clone)] struct HelloWorldServer; impl Server for HelloWorldServer { fn get_config(&self) -> Config { Config { bind_address: SocketAddr { ip: Ipv4Addr(127, 0, 0, 1), port: 8001 } } } fn handle_request(&self, _r: Request, w: &mut ResponseWriter) { w.headers.date = Some(time::now_utc()); w.headers.content_length = Some(14); w.headers.content_type = Some(MediaType { type_: String::from_str("text"), subtype: String::from_str("plain"), parameters: vec!((String::from_str("charset"), String::from_str("UTF-8"))) }); w.headers.server = Some(String::from_str("Example")); w.write(b"Hello, World!\n").unwrap(); } } fn main() { HelloWorldServer.serve_forever(); } Go (native) package main import ( "fmt" "net/http" ) func handler(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "Hi there, I love %s!", r.URL.Path[1:]) } func main() { http.HandleFunc("/", handler) http.ListenAndServe(":8080", nil) } Yeah, ok.
In Why Go Is Not Good
zkirill·Jun 29, 2014Recommendation phrase
Haskell (with third party library) http://snapframework.com/docs/tutorials/snap-api main :: IO () main = quickHttpServe site site :: Snap () site = ifTop (writeBS "hello world") <|> route [ ("foo", writeBS "bar") , ("echo/:echoparam", echoHandler) ] <|> dir "static" (serveDirectory ".") echoHandler :: Snap () echoHandler = do param <- getParam "echoparam" maybe (writeBS "must specify echo/param in URL") writeBS param ----- Rust (with third party library) https://github.com/chris-morgan/rust-http/blob/master/src/ex... //! A very simple HTTP server which responds with the plain text "Hello, World!" to every request. #![crate_id = "hello_world"] extern crate time; extern crate http; use std::io::net::ip::{SocketAddr, Ipv4Addr}; use std::io::Writer; use http::server::{Config, Server, Request,
Read the rest
ResponseWriter}; use http::headers::content_type::MediaType; #[deriving(Clone)] struct HelloWorldServer; impl Server for HelloWorldServer { fn get_config(&self) -> Config { Config { bind_address: SocketAddr { ip: Ipv4Addr(127, 0, 0, 1), port: 8001 } } } fn handle_request(&self, _r: Request, w: &mut ResponseWriter) { w.headers.date = Some(time::now_utc()); w.headers.content_length = Some(14); w.headers.content_type = Some(MediaType { type_: String::from_str("text"), subtype: String::from_str("plain"), parameters: vec!((String::from_str("charset"), String::from_str("UTF-8"))) }); w.headers.server = Some(String::from_str("Example")); w.write(b"Hello, World!\n").unwrap(); } } fn main() { HelloWorldServer.serve_forever(); } ----- Go (native) package main import ( "fmt" "net/http" ) func handler(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "Hi there, I love %s!", r.URL.Path[1:]) } func main() { http.HandleFunc("/", handler) http.ListenAndServe(":8080", nil) } ----- Yeah, ok.
In Why Go Is Not Good
Kinda, yes, but not really. Currently, the best http framework in Rust is rust-http (https://github.com/chris-morgan/rust-http) and it has the things needed for handling requests and sending responses. But as far as actual full featured web frameworks, there is only one that I know of (discounting mre since it hasn't been updated in a long time) and that's because I am the creator of it. oxidize (https://github.com/jroweboy/oxidize) aims to be an inherently safe and fast web framework inspired by several other frameworks, but I don't consider oxidize to be even in a pre alpha state right now (pre alpha to me means, don't try to write code with it cause it will change drastically in the near future). I've rewritten the code for it twice already and a third time is sitting in a branch that doesn't compile right now. Progress has been a litt
Read the rest
le slow lately since it became a group project for a class of mine, and that meant that I needed to manage several people working on it rather than actually contributing code. Over the summer I hope to get it in a good state and then make a post about it and fill out documentation, make tests, submit it to techempower benchmarks, and other necessities. Having said that, I'm not confident yet that you want to be coding a web site in rust. In the name of safety, rust's compiler can be very difficult to please and in the name of speed it doesn't compile blazingly fast as well. Some people may have a different opinion from me, but besides writing a web app to learn the rust language, what advantages for the web does rust give you that go or haskell doesn't? When you are writing a web app, developer productivity is priority number one (in my opinion), and having to fight the borrow/lifetime checker and trying to find out why your struct doesn't fulfil `Send` are not things I would like to have to do when I'm making a web site. The tradeoff will be that hopefully a web site written in rust will be both fast and concurrently safe, but you will be sacrificing developer productivity for the reasons mentioned above. Irregardless of those issues, I'm still very determined to make a rust web framework that is both fast and easy to develop for (probably by providing examples of common web idioms in oxidize so people can see how to do it), just, I want people that use my framework to be aware of the tradeoffs that they will make. In short, I consider oxidize an experiment in trying to make a powerful, expressive, and extensible web framework in rust, and along the way I've started to question whether this will have any practical applications, but in spite of that, I still am trying to achieve the previous listed goals.
In Rust for C++ programmers – part 3: primitive types and operators
I don't see how you make the leap from a syntax you don't like, to the language lacking cohesion. In my experience Rust code looks perfectly cohesive, and once you have the sigils in your head you simply parse them as what they mean. To give an example, I don't believe that this code: https://github.com/chris-morgan/rust-http/blob/master/src/ex... is any less cohesive than this: https://gist.github.com/thisishugo/8433714 Obviously each to their own, but I'm finding Rust a very enjoyable language to work with.
In The Periodic Table of Rust Types
At present, in rust-http, invalid values will be dropped; that will be changing so that you can retrieve a bad header value (https://github.com/chris-morgan/rust-http/issues/27). Writing invalid HTTP, on the other hand, is something that I'm in two minds about. You shouldn't be allowed to do it, but it may be necessary somewhere along the way. At present, you can write invalid headers through the use of the extension headers—`response.headers.extension.set(~"Date", ~"invalid")`, for example. I certainly don't want to advertise it broadly, but I'm thinking guaranteeing that that will always work is perhaps the best plan.
In Scala – 1 Star – Would Not Program Again
The section on HTTP headers and typing is a little concerning to me. I've been making rust-http recently and (before I was aware of Spray) I felt strongly about the typing. So, I'd like to discuss this. Am I wrong after all? Here clearly is someone that disagrees with me. I think I should probably write up a long blog post on the topic explaining my reasoning and so forth. rust-http is, at present at least, rejecting the standard practice of stringly typed headers and is using strongly typed headers. > ... and even types for every ‘known’ HTTP header. > The known HTTP header part was particularly ridiculous. HTTP headers are defined as simple key/value pairs. You’re supposed to be allowed to add arbitrary headers. You’re not supposed to be constrained by the framework you’re using not having any support for CORS yet. He has taken a strong
Read the rest
position against this strong typing; I take a similarly strong position for such strong typing. Yes, HTTP headers are defined as simple key/value pairs. But headers are not text; they are data. XML is defined as text. Should we use regular expressions to work with it? (True, it also has the DOM defined. But HTTP headers also have a grammar defined—it just happens to include the admissibility of extension headers.) HTTP is a serialisation format for messages; messages made up of computer-readable data, not text. I wrote a handful of paragraphs about this subject at https://github.com/chris-morgan/rust-http/issues/1 where using a map instead of typed headers was suggested. As I also note there, I would not attempt such a scheme in a language like Python (my primary language for some years) because its type system is not well adjusted to something like this; I am certain it would cause many problems and feel it likely it would cause more than it solved. But in a language with a solid type system capable of expressing these things, taking advantage of it should lead to a faster, more correct program. In the end, I believe strongly typed headers are a good thing to have (it will actually make most code distinctly nicer—e.g. ``response.headers.date = Some(now())`` instead of ``response.headers.set("Date", now().to_http_header())``). The implementation of the scheme in rust-http is certainly not perfect yet; I'm not happy with it at present; I'm expecting to turn the extension headers into a trait object, and I've even considered crazy ideas like allowing users of the library to make their own header collection (request.headers and response.headers) types—that would allow custom headers to be made first-class citizens but could lead to compatibility problems. Still, I don't want to make something that I believe should be the best HTTP library around and find that people hate to use it. What do you think about this header matter?
In Scala – 1 Star – Would Not Program Again
That's my hope. I have one or two ideas that I haven't seen elsewhere and various other ideas that I hadn't seen elsewhere until I looked at certain esoteric frameworks like Yesod (plus a couple of other Haskell ones and Ur/Web), as well as all the normal ideas. Three of my key goals are speed, safety and correctness, all things that are simply lacking (and often drive people away from them in the end) in frameworks like Ruby on Rails and Django (which, incidentally, has been my preferred framework with Python as my preferred language). However, before I can build the web framework I want in Rust, I'm having to write the HTTP library I want in Rust (with similar goals), and that's the stage I'm currently at: http://github.com/chris-morgan/rust-http.
In Ask HN: In 2016, will Rails & Django be competitive against newer technologies?
A language like Python or Ruby gets you ease of coding and a moderate level of safety; a language like C gets you speed but at a high safety risk. Haskell could get you often similar speed benefits, and there are even a couple of rather interesting frameworks for it (with even things like compile-time template checking), but the barrier for entry is unfortunately high. Thus a language like Rust really comes into its own: speed kin to C with safety significantly exceeding that of Python and Ruby. Users of Python and Ruby may find the parts of its type system which must be specified explicitly arduous, but it does make it ever so much more likely that code that you write just works, correctly, which (as primarily a Python developer) I have found marvellous. Rust isn't there yet for web development, but solid support for the HTTP layer is we
Read the rest
ll in progress: https://github.com/chris-morgan/rust-http. When that's far enough along, then I'll get on to the framework I have in mind.
In Web development in C: Crazy?
I've been working on implementing a solid HTTP library in Rust, currently at http://github.com/chris-morgan/rust-http. Servo has been using Joyent's HTTP parser and this is a problem that I had observed with it. Yes, it is pretty badly implemented, but it's not a mess because of the style of code—that's for performance. It's only a mess because it's inconsistent and incorrect. Reading the HTTP method in a high-performance way does lead to superficially ugly code. That's why code generation is good. Ragel has been mentioned and I intend to seriously consider using it, but for the moment my own HTTP method reading code is generated with: generate_branchified_method( writer, branchify!(case sensitive, "CONNECT" => Connect, "DELETE" => Delete, "GET" => Get, "HEAD" =>
Read the rest
Head, "OPTIONS" => Options, "PATCH" => Patch, "POST" => Post, "PUT" => Put, "TRACE" => Trace ), 1, "self.stream.read_byte()", "SP", "MAX_METHOD_LEN", "is_token_item(b)", "ExtensionMethod(%s)"); This is pleasantly easy to read and meaningful. This generates the high performance artwork shown at http://sprunge.us/HdTH, which supports extension methods correctly. (Rust's algebraic data types are marvellous for many things in implementing such a spec.)
In Node.js incorrectly parses HTTP methods

MAKE YOURSELF AT HOME

A few shortcuts

/
Search the collection
?
Open this guide
Esc
Close dialogs and navigation

Your saved repositories and interests stay in this browser.