Skip to content

Commit 30bb494

Browse files
Merge pull request jonasmalacofilho#2 from tonin/master
Support gzip encoded requests from git clients Fixes jonasmalacofilho#1
2 parents 89b8c84 + aceeefd commit 30bb494

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed

README.md

+22-3
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,20 @@ the remote hostname.
2727
Example:
2828

2929
```
30-
$ git-cache-http-server --port 1234 --cache-dir /tmp/cache/git &
31-
$ git clone http://localhost:1234/github.com/jonasmalacofilho/git-cache-http-server
30+
git-cache-http-server --port 1234 --cache-dir /tmp/cache/git &
31+
git clone http://localhost:1234/github.com/jonasmalacofilho/git-cache-http-server
32+
```
33+
34+
If you run your git-cache on a dedicated server or container (i.e. named gitcache), you can then also configure git to always use your cache like in the following example (don't use this configuration on the git-cache machine itself):.
35+
```
36+
git config --global url."http://gitcache:1234/".insteadOf https:// && \
3237
```
3338

3439
# Installing
3540

3641
Requirements: `nodejs` and `git`.
3742

38-
Install: `npm install -g jonasmalacofilho/git-cache-http-server`
43+
Install: `npm install -g git-cache-http-server`
3944

4045
To install as a service, check the `doc/git-cache-http-server.service` example
4146
service file.
@@ -49,6 +54,20 @@ systemctl daemon-reload
4954
systemctl start git-cache-http-server
5055
```
5156

57+
# Building from source
58+
59+
This is needed only if you change the Haxe source code in `src/`.
60+
61+
Requirements: `haxe` and `haxelib`.
62+
63+
You'll need the "hxnodejs" and the https://github.com/jonasmalacofilho/jmf-npm-externs.hx libraries before being able to compile the project.
64+
65+
```
66+
haxelib install hxnodejs
67+
haxelib git https://github.com/jonasmalacofilho/jmf-npm-externs.hx.git
68+
haxe build.hxml
69+
```
70+
5271
# Implementation
5372

5473
The current implementation is somewhat oversimplified; any help in improving it

src/Main.hx

+5-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,11 @@ class Main {
111111
res.setHeader("Content-Type", 'application/x-${params.service}-result');
112112
res.setHeader("Cache-Control", "no-cache");
113113
var up = ChildProcess.spawn(params.service, ["--stateless-rpc", local]);
114-
req.pipe(up.stdin);
114+
// If we receive gzip content, we must unzip
115+
if (req.headers['content-encoding'] == 'gzip')
116+
req.pipe(Zlib.createUnzip()).pipe(up.stdin);
117+
else
118+
req.pipe(up.stdin);
115119
up.stdout.pipe(res);
116120
up.stderr.on("data", function (data) trace('${params.service} stderr: $data'));
117121
up.on("exit", function (code) {

0 commit comments

Comments
 (0)