git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/3] t/gitweb-lib.sh: Split gitweb output into headers and body

From
Jakub Narebski <jnareb@gmail.com>
Date
Nov 7, 2009, 15:13 UTC
Message-ID
<1257606809-23287-2-git-send-email-jnareb@gmail.com>
In-Reply-To
<1257606809-23287-1-git-send-email-jnareb@gmail.com>

Save HTTP headers into gitweb.headers, and the body of message into gitweb.body in gitweb_run()

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
This version is identical to the one in previous version of this
series.
I hope that this use of sed is portable enough.

Please take into account that HTTP headers part contains at least one line: HTTP status.

 t/gitweb-lib.sh |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/t/gitweb-lib.sh b/t/gitweb-lib.sh
index 8452532..32b841d
--- a/t/gitweb-lib.sh
+++ b/t/gitweb-lib.sh
@@ -52,10 +52,14 @@ gitweb_run () {
 	rm -f gitweb.log &&
 	perl -- "$SCRIPT_NAME" \
 		>gitweb.output 2>gitweb.log &&
+	sed -e   '/^\r$/q' <gitweb.output >gitweb.headers &&
+	sed -e '1,/^\r$/d' <gitweb.output >gitweb.body    &&
 	if grep '^[[]' gitweb.log >/dev/null 2>&1; then false; else true; fi
 
 	# gitweb.log is left for debugging
-	# gitweb.output is used to parse http output
+	# gitweb.output is used to parse HTTP output
+	# gitweb.headers contains only HTTP headers
+	# gitweb.body contains body of message, without headers
 }
 
 . ./test-lib.sh
-- 
1.6.5
Previous: Jakub NarebskiNext: Jakub Narebski
Message 2 of 4 in “[PATCHv2 0/3] gitweb: Smarter snapshot names”
  1. Jakub NarebskiNov 7, 2009
  2. 1/3 t/gitweb-lib.sh: Split gitweb output into headers and bodyJakub Narebski, Nov 7, 2009
  3. 2/3 gitweb: Document current snapshot rules via new testsJakub Narebski, Nov 7, 2009
  4. 3/3 gitweb: Smarter snapshot namesJakub Narebski, Nov 7, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.