Skip to content

Commit

Permalink
Fixes #559 : when HTTP/2 is used, header names are lower case. So add…
Browse files Browse the repository at this point in the history
…ing ignore case option (-i) to grep's.
  • Loading branch information
Florent authored and lukas2511 committed May 9, 2018
1 parent 2a8af8f commit e4e712c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions dehydrated
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ init_system() {
if [[ ${API} -eq 1 ]]; then
_exiterr "This is not implemented for ACMEv1! Consider switching to ACMEv2 :)"
else
ACCOUNT_URL="$(signed_request "${CA_NEW_ACCOUNT}" '{"onlyReturnExisting": true}' 4>&1 | grep ^Location: | awk '{print $2}' | tr -d '\r\n')"
ACCOUNT_URL="$(signed_request "${CA_NEW_ACCOUNT}" '{"onlyReturnExisting": true}' 4>&1 | grep -i ^Location: | awk '{print $2}' | tr -d '\r\n')"
ACCOUNT_INFO="$(signed_request "${ACCOUNT_URL}" '{}')"
fi
ACCOUNT_ID="${ACCOUNT_URL##*/}"
Expand Down Expand Up @@ -579,9 +579,9 @@ signed_request() {

# Retrieve nonce from acme-server
if [[ ${API} -eq 1 ]]; then
nonce="$(http_request head "${CA}" | grep Replay-Nonce: | awk -F ': ' '{print $2}' | tr -d '\n\r')"
nonce="$(http_request head "${CA}" | grep -i Replay-Nonce: | awk -F ': ' '{print $2}' | tr -d '\n\r')"
else
nonce="$(http_request head "${CA_NEW_NONCE}" | grep Replay-Nonce: | awk -F ': ' '{print $2}' | tr -d '\n\r')"
nonce="$(http_request head "${CA_NEW_NONCE}" | grep -i Replay-Nonce: | awk -F ': ' '{print $2}' | tr -d '\n\r')"

This comment has been minimized.

Copy link
@LynxChaus

LynxChaus Oct 31, 2018

Contributor

Why not use only awk here?
nonce="$(http_request head "${CA_NEW_NONCE}" | awk 'BEGIN{ IGNORECASE=1; } /^replay-nonce: / {print $2}')"
return same filed value without grep + tr and multiple forks.

This comment has been minimized.

Copy link
@lukas2511

lukas2511 Oct 31, 2018

Member

i don't really care about that tiny bit of performance and i think simple grep and tr operations are a lot easier to read

This comment has been minimized.

Copy link
@LynxChaus

LynxChaus Oct 31, 2018

Contributor

tiny - on SSD. But when it run on busy old good rotational drive....
awk 'tolower($1) ~ /replay-nonce/ {print $2}' is better than awk 'BEGIN{ IGNORECASE=1; } /^replay-nonce: / {print $2}'

This comment has been minimized.

Copy link
@lukas2511

lukas2511 Nov 1, 2018

Member

those tools are tiny and are definitively cached in memory, i would almost guarantee you that there'll be no hard-drive activity at all

fi

# Build header with just our public key and algorithm information
Expand Down

0 comments on commit e4e712c

Please sign in to comment.