I'm trying to download a firmware.bin
file that is produced in a private GitHub repository. I have the code that is finding the right asset URL to download the file and per GitHub instructions the accept
header needs to be set to accept: application/octet-stream
in order to get the binary file.
I'm only getting JSON in response. If I run the same request through postman I'm getting a binary file as the body. I've tried downloading it using HTTPClient and I get the same JSON request. It seems the headers aren't being set as requested to tell GitHub to send the binary content as I'm just getting JSON
As for the ArduinoOTA abstraction, I can't see how to even try to set headers and in digging into the esp_https_ota
functions and http_client
functions there doesn't appear to be a way to set headers for any of these higher level abstractions because the http_config
object has no place for headers as far as I can tell. I might file a feature request to allow for this, but am new to this programming area and want to check to see if I'm missing something first.
Code returns JSON, not binary. URL is GitHub rest API URL to the asset (works in postman)
HTTPClient http2;
http2.setAuthorization(githubname,githubpass);
http2.addHeader("Authorization","token MYTOKEN");
http2.addHeader("accept","application/octet-stream");
http2.begin( firmwareURL, GHAPI_CERT); //Specify the URL and certificate