Permalink
Browse files

headers_sock belongs to router.sh

  • Loading branch information...
1 parent 8d25576 commit 421d267fe3448078250e7bc18bb5e5d528b0c46a @jneen committed Jan 12, 2011
Showing with 6 additions and 5 deletions.
  1. +2 −0 lib/balls.sh
  2. +4 −0 lib/router.sh
  3. +0 −5 lib/server.sh
View
@@ -18,4 +18,6 @@
. $BALLS_LIB/http.sh
. $BALLS_LIB/router.sh
. $BALLS_LIB/server.sh
+. $BALLS_LIB/view.sh
+
. $BALLS_ACTIONS/*.sh
View
@@ -39,6 +39,9 @@ balls::route() {
)
if [ -n "$action" ] && exists "$action"; then
+ headers_sock=$BALLS_TMP/balls.headers.$(_hash).sock
+ [ -p $headers_sock ] || mkfifo $headers_sock
+
( $action 3>$headers_sock ) | {
headers=$(cat <$headers_sock)
body=$(cat -)
@@ -52,6 +55,7 @@ balls::route() {
echo "$response" >$http_sock
}
# send the headers to the client
+ rm -f "$headers_sock"
else
if [[ "$REQUEST_METHOD" = "HEAD" ]]; then
REQUEST_METHOD=GET
View
@@ -11,14 +11,9 @@ balls::server() {
while true; do
cat $http_sock | nc -l -p $BALLS_PORT | (
- headers_sock=$TMP_DIR/balls.headers.$(_hash).sock
- [ -p $headers_sock ] || mkfifo $headers_sock
-
http::parse_request
-
balls::route
)
- rm -f $headers_sock
done
}

0 comments on commit 421d267

Please sign in to comment.