Skip to content

Commit 27da508

Browse files
committed
Merge pull request chris-morgan#14 from larsbergstrom/update_origin_branch
Update the servo branch with changes from upstream and to build in Servo
2 parents fa82ccf + 80ef656 commit 27da508

39 files changed

+402
-221
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,9 @@ build/
77
TAGS
88
doc/http/
99
doc/src/http/
10+
doc/.lock
11+
doc/*.js
12+
doc/*.css
1013
lib/
1114
.rust/
15+
Makefile

.hgignore

+5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
~$
22
\.dSYM/
3+
\.swp$
34
^src/http/generated/
45
^bin/
56
^build/
67
^TAGS$
78
^doc/http/
89
^doc/src/http/
10+
^doc/\.lock$
11+
^doc/.*\.js$
12+
^doc/.*\.css$
913
^lib/
1014
^.rust/
15+
^Makefile$

.travis.yml

+10-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,16 @@ before_install:
66
- sudo apt-get update
77
install:
88
- sudo apt-get install rust-nightly
9+
- git clone https://github.com/sfackler/rust-openssl.git
10+
- cd rust-openssl
11+
- ./configure
12+
- make
13+
- cd ..
14+
- mv rust-openssl ../
915
script:
10-
- make check
11-
- make docs
16+
- WITHOUT_SSL=1 ./configure
17+
- make all check
18+
- ./configure
19+
- make all check docs
1220
after_script:
1321
- curl http://www.rust-ci.org/artifacts/put?t=$RUSTCI_TOKEN | sh

Makefile

-80
This file was deleted.

Makefile.in

+78-29
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,91 @@
1-
VPATH=%VPATH%
2-
3-
RUST ?= rust
1+
SSL_LIB ?= %SSL_LIB%
2+
SSL_CFG ?= %SSL_CFG%
3+
ifdef SSL_LIB
4+
SSL_CFG += -L "$(SSL_LIB)"
5+
endif
46
RUSTC ?= rustc
5-
RUSTFLAGS ?= -O
6-
HOST_RUSTFLAGS ?= -O
7+
RUSTDOC ?= rustdoc
8+
RUSTPKG ?= rustpkg
9+
RUSTFLAGS ?= -O $(SSL_CFG)
10+
RUST_REPOSITORY ?= ../rust
11+
RUST_CTAGS ?= $(RUST_REPOSITORY)/src/etc/ctags.rust
712
VERSION=0.1-pre
813

9-
libhttp_files=$(shell find $(VPATH)/src/http/ -type f -name '*.rs') \
10-
$(VPATH)/src/http/generated/read_method.rs \
11-
$(VPATH)/src/http/generated/status.rs
14+
codegen_files=\
15+
src/codegen/branchify.rs \
16+
src/codegen/main.rs \
17+
src/codegen/read_method.rs \
18+
src/codegen/status.rs \
19+
20+
libhttp_so=build/.libhttp.timestamp
21+
http_files=\
22+
$(wildcard src/http/*.rs) \
23+
src/http/generated/read_method.rs \
24+
src/http/generated/status.rs \
25+
$(wildcard src/http/headers/*.rs) \
26+
$(wildcard src/http/client/*.rs) \
27+
$(wildcard src/http/server/*.rs)
28+
29+
http: $(libhttp_so)
30+
31+
Makefile: configure Makefile.in
32+
@echo "configure or Makefile.in changed, regenerating Makefile"
33+
@DOING_RECONFIGURE=1 SSL_LIB="$(SSL_LIB)" SSL_CFG="$(SSL_CFG)" ./configure
34+
@echo
35+
@echo ======================
36+
@echo Please run make again!
37+
@echo ======================
38+
@echo
39+
@exit 1
40+
41+
$(libhttp_so): Makefile $(http_files)
42+
mkdir -p build/
43+
$(RUSTC) $(RUSTFLAGS) src/http/lib.rs --out-dir=build
44+
@touch build/.libhttp.timestamp
45+
46+
all: http examples docs
47+
48+
build/codegen: $(codegen_files)
49+
mkdir -p build/
50+
$(RUSTC) src/codegen/main.rs --out-dir=build
51+
52+
src/http/generated:
53+
mkdir -p src/http/generated
54+
55+
src/http/generated/%.rs: build/codegen src/http/generated
56+
build/codegen $(patsubst src/http/generated/%,%,$@) src/http/generated/
57+
58+
build/%:: src/%/main.rs $(libhttp_so)
59+
mkdir -p "$(dir $@)"
60+
$(RUSTC) $(RUSTFLAGS) $< -o $@ -L build/
1261

13-
all: libhttp.dummy
62+
examples: $(patsubst src/examples/%/main.rs,build/examples/%,$(wildcard src/examples/*/main.rs)) \
63+
$(patsubst src/examples/%/main.rs,build/examples/%,$(wildcard src/examples/*/*/main.rs))
1464

15-
codegen: $(wildcard $(VPATH)/src/codegen/*.rs)
16-
$(RUSTC) $(HOST_RUSTFLAGS) $(VPATH)/src/codegen/main.rs -o codegen
65+
docs: doc/http/index.html
1766

18-
$(VPATH)/src/http/generated:
19-
mkdir -p $(VPATH)/src/http/generated
67+
doc/http/index.html: $(http_files)
68+
$(RUSTDOC) src/http/lib.rs
2069

21-
$(VPATH)/src/http/generated/%.rs: codegen $(VPATH)/src/http/generated
22-
./codegen $(patsubst $(VPATH)/src/http/generated/%,%,$@) $(VPATH)/src/http/generated/
70+
build/tests: $(http_files)
71+
$(RUSTC) $(RUSTFLAGS) --test -o build/tests src/http/lib.rs
2372

24-
libhttp.dummy: $(libhttp_files)
25-
$(RUSTC) $(RUSTFLAGS) $(VPATH)/src/http/lib.rs --out-dir .
26-
touch $@
73+
build/quicktests: $(http_files)
74+
$(RUSTC) --test -o build/quicktests src/http/lib.rs
2775

28-
check: tests
29-
./tests --test
76+
# Can't wait for everything to build, optimised too? OK, you can save some time here.
77+
quickcheck: build/quicktests
78+
build/quicktests --test
3079

31-
tests: $(libhttp_files)
32-
$(RUSTC) $(RUSTFLAGS) --test -o tests $(VPATH)/src/http/lib.rs
80+
check: all build/tests
81+
build/tests --test
3382

34-
clean-tests:
35-
rm -f tests
83+
clean:
84+
rm -rf src/http/generated/ src/http/codegen/codegen
85+
rm -rf build/
86+
rm -rf bin/ .rust/
3687

37-
clean: clean-tests
38-
rm -rf $(VPATH)src/http/generated/ codegen
39-
rm -rf libhttp.dummy
40-
rm -f *.so *.dylib *.rlib *.dll
88+
TAGS:
89+
ctags -f TAGS --options=$(RUST_CTAGS) -R src
4190

42-
.PHONY: all examples clean clean-tests
91+
.PHONY: all http examples docs clean check quickcheck

Makefile.servo.in

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
VPATH=%VPATH%
2+
3+
RUST ?= rust
4+
RUSTC ?= rustc
5+
RUSTFLAGS ?= -O
6+
HOST_RUSTFLAGS ?= -O
7+
VERSION=0.1-pre
8+
9+
libhttp_files=$(shell find $(VPATH)/src/http/ -type f -name '*.rs') \
10+
$(VPATH)/src/http/generated/read_method.rs \
11+
$(VPATH)/src/http/generated/status.rs
12+
13+
all: libhttp.dummy
14+
15+
codegen: $(wildcard $(VPATH)/src/codegen/*.rs)
16+
$(RUSTC) $(HOST_RUSTFLAGS) $(VPATH)/src/codegen/main.rs -o codegen
17+
18+
$(VPATH)/src/http/generated:
19+
mkdir -p $(VPATH)/src/http/generated
20+
21+
$(VPATH)/src/http/generated/%.rs: codegen $(VPATH)/src/http/generated/
22+
./codegen $(patsubst $(VPATH)/src/http/generated/%,%,$@) $(VPATH)/src/http/generated/
23+
24+
libhttp.dummy: $(libhttp_files)
25+
$(RUSTC) $(RUSTFLAGS) $(VPATH)/src/http/lib.rs --out-dir .
26+
touch $@
27+
28+
build/%:: src/%.rs libhttp.dummy
29+
mkdir -p '$(dir $@)'
30+
$(RUSTC) $(RUSTFLAGS) $< -o $@ -L build/
31+
32+
examples: build/examples/apache_fake build/examples/hello_world build/examples/info build/examples/client/client
33+
34+
.PHONY: check
35+
check: tests
36+
37+
tests: $(libhttp_files)
38+
$(RUSTC) $(RUSTFLAGS) --test -o tests $(VPATH)/src/http/lib.rs
39+
./tests --test
40+
41+
clean-tests:
42+
rm -f tests
43+
44+
clean: clean-tests
45+
rm -rf $(VPATH)src/http/generated/ codegen
46+
rm -rf libhttp.dummy
47+
rm -f *.so *.dylib *.dll
48+
49+
.PHONY: all examples clean tests clean-tests

README.rst

+16
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,22 @@ At present, all of the example servers serve to http://127.0.0.1:8001/.
6868
Don't expect everything to work well. The server claims HTTP/1.1, but is not
6969
in any way compliant yet.
7070

71+
SSL support
72+
-----------
73+
74+
rust-http can be compiled with or without SSL support.
75+
76+
To compile with SSL support, drop rust-openssl_ in a sibling directory of
77+
rust-http (i.e. ``../rust-openssl`` from this file) and run its ``configure``
78+
and ``make``. rust-http's ``configure`` will then automatically detect it and
79+
you will get SSL support enabled.
80+
81+
To compile rust-http without SSL support, just don’t put rust-openssl_ where it
82+
can find it. You'll then get an ``IoError { kind: InvalidInput, .. }`` if you
83+
try to make an SSL request (e.g. HTTPS).
84+
85+
.. _rust-openssl: https://github.com/sfackler/rust-openssl
86+
7187
Roadmap
7288
-------
7389

comparisons/run.py

+3
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,9 @@ def compile_server(self):
144144
'--opt-level=3', self.source,
145145
#'--out-dir', self.build_dir,
146146
'-L', '../build', # '../build/{}/http/'.format(RustServerRunner.HOST),
147+
# Just in case it was built with openssl support. This should
148+
# really be done better, based on the Makefile contents.
149+
'-L', '../../rust-openssl/build',
147150
# Sorry, this main.rs business needs me to do this, or use rustpkg:
148151
'-o', os.path.join(self.build_dir, self.bin_name))).communicate()
149152

configure

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/bin/bash
22

33
SRCDIR="$(cd $(dirname $0) && pwd)"
4-
sed "s#%VPATH%#${SRCDIR}#" ${SRCDIR}/Makefile.in > Makefile
4+
sed "s#%VPATH%#${SRCDIR}#" ${SRCDIR}/Makefile.servo.in > Makefile

src/codegen/branchify.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#[macro_escape];
1+
#![macro_escape]
22

33
use std::str::Chars;
44
use std::io::IoResult;

src/codegen/main.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#[crate_id = "codegen"];
1+
#![crate_id = "codegen"]
22

3-
#[feature(macro_rules)];
3+
#![feature(macro_rules)]
44

55
extern crate collections;
66

src/examples/client/main.rs

+9-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
#[crate_id = "client"];
1+
#![crate_id = "client"]
22

33
extern crate http;
44
use http::client::RequestWriter;
55
use http::method::Get;
66
use http::headers::HeaderEnum;
77
use std::os;
88
use std::str;
9-
use std::io::{Reader, println};
10-
use std::io::net::tcp::TcpStream;
9+
use std::io::println;
1110

1211
fn main() {
1312
format!("{}", Get);
@@ -23,8 +22,8 @@ fn main() {
2322
}
2423

2524
fn make_and_print_request(url: ~str) {
26-
let request = RequestWriter::<TcpStream>::new(Get, from_str(url).expect("Invalid URL :-("))
27-
.unwrap();
25+
let request: RequestWriter = RequestWriter::new(Get, from_str(url).expect("Invalid URL :-("))
26+
.unwrap();
2827

2928
println!("Request");
3029
println!("=======");
@@ -51,6 +50,9 @@ fn make_and_print_request(url: ~str) {
5150
println!(" - {}: {}", header.header_name(), header.header_value());
5251
}
5352
println!("Body:");
54-
let body = response.read_to_end().unwrap();
55-
println(str::from_utf8(body).expect("Uh oh, response wasn't UTF-8"));
53+
let body = match response.read_to_end() {
54+
Ok(body) => body,
55+
Err(err) => fail!("Reading response failed: {}", err),
56+
};
57+
println(str::from_utf8(body.as_slice()).expect("Uh oh, response wasn't UTF-8"));
5658
}

0 commit comments

Comments
 (0)