acme.sh
acme.sh copied to clipboard
HTTP Headers not saved with wget
The http headers are never saved into a file when wget is used. This causes dns providers like azure to throw errors
Compare this code with the curl version (_inithttp). https://github.com/acmesh-official/acme.sh/blob/eb27013fbad733fed0f15ea86f377bbcf29c4c66/acme.sh#L1860-L1880 https://github.com/acmesh-official/acme.sh/blob/eb27013fbad733fed0f15ea86f377bbcf29c4c66/acme.sh#L1839-L1858
This is what _post does: https://github.com/acmesh-official/acme.sh/blob/eb27013fbad733fed0f15ea86f377bbcf29c4c66/acme.sh#L1990
And within _get it doesn't save the http headers and only does: https://github.com/acmesh-official/acme.sh/blob/eb27013fbad733fed0f15ea86f377bbcf29c4c66/acme.sh#L2054-L2058 _get either only saves the headers when $onlyheaders is set. Or only the content. This is unexpected for callers, as with curl (or other request types) both is saved.
And this is where I observed the error: https://github.com/acmesh-official/acme.sh/blob/master/dnsapi/dns_azure.sh#L254 This code expects the http headers to get written when the API response body is retrieved.
I remember that there is no way to output the headers and the conent into 2 separate files for wget(curl can do that).
So it was different in the _get()
function.
We can not modify the code as your changes: just redirect all the stdout to the HTTP_HEADER file. The $response
will be empty. response=$(_get .......)
but thanks for your effort, and your changes inspired me that we can mock the wget's behavior to the same as the curl's.
It will look like:
_get() {
.......
#the stdout is to the response, and the stderr is for the HTTP_HEADER
wget -O- $url 2>"$HTTP_HEADER "
_sed_i "s/^ *//g" "$HTTP_HEADER " #trim out the heading spaces in the header file
.......
Would you mind trying it again? and sending another PR ?
Thanks
updated my PR, now it demultiplexes the output.