Skip to content

Commit 8679e14

Browse files
committed
Merge pull request chris-morgan#13 from larsbergstrom/rustup_20140410
Rustup 20140410
2 parents 2701405 + 05cfe23 commit 8679e14

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+2235
-1843
lines changed

.gitignore

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
*~
22
*.dSYM/
33
*.swp
4-
src/libhttp/codegen/codegen
5-
src/libhttp/generated/
4+
src/http/generated/
5+
bin/
66
build/
7+
TAGS
8+
doc/http/
9+
doc/src/http/
10+
doc/.lock
11+
doc/*.js
12+
doc/*.css
13+
lib/
14+
.rust/
15+
Makefile

.hgignore

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
11
~$
2-
^src/libhttp/codegen/codegen$
3-
^src/libhttp/generated/
2+
\.dSYM/
3+
\.swp$
4+
^src/http/generated/
5+
^bin/
46
^build/
7+
^TAGS$
8+
^doc/http/
9+
^doc/src/http/
10+
^doc/\.lock$
11+
^doc/.*\.js$
12+
^doc/.*\.css$
13+
^lib/
14+
^.rust/
15+
^Makefile$

.travis.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,21 @@
1+
env:
2+
global:
3+
- secure: SkhFtAUkRRrDYHr6z6YhWtGouw6jsys7dBKLojA+M3M68EM9U1VG9oNHMasCdFUt0a+TdPte9JccufbhvZABnlo7+yU6hQ94jhsyQ9qSL5y7V+2eyWBkQZDqyFt3jgLyrrSV2Nkk22xI4UAm2iGRKel6lXWi7i0i9hDT+3W0dK4=
14
before_install:
25
- yes | sudo add-apt-repository ppa:hansjorg/rust
36
- sudo apt-get update
47
install:
58
- 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 ../
615
script:
7-
- make check
16+
- WITHOUT_SSL=1 ./configure
17+
- make all check
18+
- ./configure
19+
- make all check docs
20+
after_script:
21+
- curl http://www.rust-ci.org/artifacts/put?t=$RUSTCI_TOKEN | sh

Makefile

Lines changed: 0 additions & 54 deletions
This file was deleted.

Makefile.in

Lines changed: 76 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +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/libhttp/ -type f -name '*.rs') \
10-
$(VPATH)/src/libhttp/generated/read_method.rs \
11-
$(VPATH)/src/libhttp/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
1245

13-
all: libhttp.dummy
46+
all: http examples docs
1447

15-
codegen: $(wildcard $(VPATH)/src/libhttp/codegen/*.rs)
16-
$(RUSTC) $(HOST_RUSTFLAGS) $(VPATH)/src/libhttp/codegen/codegen.rs -o codegen
48+
build/codegen: $(codegen_files)
49+
mkdir -p build/
50+
$(RUSTC) src/codegen/main.rs --out-dir=build
1751

18-
$(VPATH)/src/libhttp/generated/%.rs: codegen
19-
./codegen $(patsubst $(VPATH)/src/libhttp/generated/%,%,$@) $(VPATH)/src/libhttp/generated/
52+
src/http/generated:
53+
mkdir -p src/http/generated
2054

21-
libhttp.dummy: $(libhttp_files)
22-
$(RUSTC) $(RUSTFLAGS) $(VPATH)/src/libhttp/lib.rs --out-dir .
23-
touch $@
55+
src/http/generated/%.rs: build/codegen src/http/generated
56+
build/codegen $(patsubst src/http/generated/%,%,$@) src/http/generated/
2457

25-
build/%:: src/%.rs libhttp.dummy
26-
mkdir -p '$(dir $@)'
58+
build/%:: src/%/main.rs $(libhttp_so)
59+
mkdir -p "$(dir $@)"
2760
$(RUSTC) $(RUSTFLAGS) $< -o $@ -L build/
2861

29-
examples: build/examples/apache_fake build/examples/hello_world build/examples/info build/examples/client/client
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))
64+
65+
docs: doc/http/index.html
66+
67+
doc/http/index.html: $(http_files)
68+
$(RUSTDOC) src/http/lib.rs
69+
70+
build/tests: $(http_files)
71+
$(RUSTC) $(RUSTFLAGS) --test -o build/tests src/http/lib.rs
72+
73+
build/quicktests: $(http_files)
74+
$(RUSTC) --test -o build/quicktests src/http/lib.rs
3075

31-
.PHONY: check
32-
check: tests
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
3379

34-
tests: $(libhttp_files)
35-
$(RUSTC) $(RUSTFLAGS) --test -o tests $(VPATH)/src/libhttp/lib.rs
36-
./tests --test
80+
check: all build/tests
81+
build/tests --test
3782

38-
clean-tests:
39-
rm -f tests
83+
clean:
84+
rm -rf src/http/generated/ src/http/codegen/codegen
85+
rm -rf build/
86+
rm -rf bin/ .rust/
4087

41-
clean: clean-tests
42-
rm -rf $(VPATH)src/libhttp/generated/ codegen
43-
rm -rf libhttp.dummy
44-
rm -f *.so *.dylib *.dll
88+
TAGS:
89+
ctags -f TAGS --options=$(RUST_CTAGS) -R src
4590

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

Makefile.servo.in

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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/http/codegen/*.rs)
16+
$(RUSTC) $(HOST_RUSTFLAGS) $(VPATH)/src/http/codegen/codegen.rs -o codegen
17+
18+
$(VPATH)/src/http/generated/%.rs: codegen
19+
./codegen $(patsubst $(VPATH)/src/http/generated/%,%,$@) $(VPATH)/src/http/generated/
20+
21+
libhttp.dummy: $(libhttp_files)
22+
$(RUSTC) $(RUSTFLAGS) $(VPATH)/src/http/lib.rs --out-dir .
23+
touch $@
24+
25+
build/%:: src/%.rs libhttp.dummy
26+
mkdir -p '$(dir $@)'
27+
$(RUSTC) $(RUSTFLAGS) $< -o $@ -L build/
28+
29+
examples: build/examples/apache_fake build/examples/hello_world build/examples/info build/examples/client/client
30+
31+
.PHONY: check
32+
check: tests
33+
34+
tests: $(libhttp_files)
35+
$(RUSTC) $(RUSTFLAGS) --test -o tests $(VPATH)/src/http/lib.rs
36+
./tests --test
37+
38+
clean-tests:
39+
rm -f tests
40+
41+
clean: clean-tests
42+
rm -rf $(VPATH)src/http/generated/ codegen
43+
rm -rf libhttp.dummy
44+
rm -f *.so *.dylib *.dll
45+
46+
.PHONY: all examples clean tests clean-tests

README.rst

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,37 @@ This project has two parts:
1313
Both are in progress; both have basic, low-level implementations in place.
1414
Neither is complete nor yet compliant in any way.
1515

16+
Rust versions
17+
-------------
18+
19+
I urge you to track Rust master as rust-http does, but if you really are set on
20+
using Rust 0.9, you can use the [`rust-0.9-compatible`
21+
branch](https://github.com/chris-morgan/rust-http/commits/rust-0.9-compatible).
22+
It is not maintained, however; it's just the last commit that *will* work on
23+
Rust 0.9.
24+
1625
Goals
1726
-----
1827

1928
The goal of the present phase of this project is, quite simply, to create a
2029
generic HTTP server and client library for Rust.
2130

22-
Eventually the client and server may be placed in different crates (with a
23-
common dependency), but I'm not sure about this yet.
31+
When I say “generic”, generic is what I mean: it is quite feasible to write
32+
non-origin servers (e.g. a proxy or a gateway) with rust-http; there will
33+
merely be a slightly higher level abstraction available for origin servers to
34+
use.
35+
36+
At present this is all one crate, but it may be separated into multiple crates
37+
(e.g. common HTTP, client, server); I am not sure about this yet.
2438

25-
This server is not opinionated; it provides the tools, handles communication,
26-
the HTTP/1.1 protocol and the basic headers and then leaves the rest to you.
27-
Things like URL routing do not belong in here; that is the domain of a
28-
framework.
39+
This server is not (in the normal sense) opinionated; it provides the tools,
40+
handles communication, the HTTP/1.1 protocol and the basic headers and then
41+
leaves the rest to you. Things like URL routing do not belong in here; that is
42+
the domain of a framework.
43+
44+
There is, however, one thing on which it has strong opinions: using the type
45+
system. rust-http forces you to make type-safe code. This has benefits in
46+
safety and correctness, and also typically in speed.
2947

3048
Getting started
3149
---------------
@@ -35,21 +53,37 @@ branch.
3553

3654
Build everything::
3755

38-
make
56+
make all
3957

4058
Run one of the servers::
4159

42-
build/examples/apache_fake
60+
build/examples/server/apache_fake
4361

4462
To run the client example, start one of the servers and run::
4563

46-
build/examples/client/client
64+
build/examples/client http://127.0.0.1:8001/
4765

4866
At present, all of the example servers serve to http://127.0.0.1:8001/.
4967

5068
Don't expect everything to work well. The server claims HTTP/1.1, but is not
5169
in any way compliant yet.
5270

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+
5387
Roadmap
5488
-------
5589

0 commit comments

Comments
 (0)