From a68b9c65a34a8731dec366bad25af92998d085b6 Mon Sep 17 00:00:00 2001 From: Seth House Date: Fri, 2 Nov 2018 13:06:38 -0600 Subject: [PATCH] Match headers on crlf instead of cr This matches the spec. Although it did work previously, I wonder if this may solve some issues reported where the headers and body weren't getting parsed apart correctly. The spec also allows for a single line feed separator as well so we may want to add a check for that in the future. --- ok.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ok.sh b/ok.sh index 38edb04..eaf15a2 100755 --- a/ok.sh +++ b/ok.sh @@ -78,7 +78,7 @@ awk_bin=$(command -v awk) # Generate a carriage return so we can match on it. # Using a variable because these are tough to specify in a portable way. -cr=$(printf '\r') +crlf=$(printf '\r\n') # ## Main # Generic functions not necessarily specific to working with GitHub. @@ -747,7 +747,7 @@ _response() { _log debug 'Processing response.' read -r http_version status_code status_text - status_text="${status_text%${cr}}" + status_text="${status_text%${crlf}}" http_version="${http_version#HTTP/}" _log debug "Response status is: ${status_code} ${status_text}" @@ -758,8 +758,8 @@ status_text: ${status_text} " while IFS=": " read -r hdr val; do # Headers stop at the first blank line. - [ "$hdr" = "$cr" ] && break - val="${val%${cr}}" + [ "$hdr" = "$crlf" ] && break + val="${val%${crlf}}" # Process each header; reformat some to work better with sh tools. case "$hdr" in