Skip to content

Boards Manager URLs incorrect HTTP GET Range header field #6628

Closed
@kosza

Description

@kosza

I am using Arduino 1.8.3.
I added http://arduino.esp8266.com/stable/package_esp8266com_index.json to Boards Manager URLs and got a downloading error.

I checked the traffic and discovered that the HTTP request is incorrect: Range: bytes=26000-
It should be Range: bytes=0- or it shouldn't be.

Here is the http request and reply:
GET /versions/2.3.0/package_esp8266com_index.json HTTP/1.1
User-agent: ArduinoIDE/1.8.3 Java/1.8.0_121
Range: bytes=26000-
Host: arduino.esp8266.com
Accept: text/html, image/gif, image/jpeg, *; q=.2, /; q=.2
Connection: keep-alive

HTTP/1.1 416 Requested Range Not Satisfiable
X-Powered-By: Express
Accept-Ranges: bytes
Cache-Control: public, max-age=0
Last-Modified: Sat, 06 May 2017 03:02:19 GMT
ETag: W/"6590-15bdbb53a78"
Content-Type: text/html; charset=utf-8
Content-Range: bytes */26000
X-Content-Type-Options: nosniff
Content-Length: 459
Date: Thu, 17 Aug 2017 06:23:05 GMT
Connection: keep-alive

RangeNotSatisfiableError: Range Not Satisfiable
   at SendStream.error (/home/nodeuser/apps/download/node_modules/express/node_modules/send/index.js:275:31)
   at SendStream.send (/home/nodeuser/apps/download/node_modules/express/node_modules/send/index.js:618:19)
   at onstat (/home/nodeuser/apps/download/node_modules/express/node_modules/send/index.js:677:10)
   at Object.oncomplete (fs.js:107:15)

Regards,
Kosza

Activity

facchinm

facchinm commented on Aug 17, 2017

@facchinm
Member

mmmh, wrong project?
All the node output is surely not part of Arduino. Are you sure you are using IDE 1.8.3

Sorry I totally misread the post

added
Type: InvalidOff topic for this repository, or a bug report determined to not actually represent a bug
on Aug 17, 2017
removed
Type: InvalidOff topic for this repository, or a bug report determined to not actually represent a bug
on Aug 17, 2017
facchinm

facchinm commented on Aug 17, 2017

@facchinm
Member

Hi @kosza , can you paste here the output from the IDE console when the download fails?
I'm unable to reproduce it with the same link, so I think it could be caused by some network problems on your side (or related with the json providers).

kosza

kosza commented on Aug 17, 2017

@kosza
Author
facchinm

facchinm commented on Aug 17, 2017

@facchinm
Member

But if you click the link you are able to see the json, right? What happens if you add, for example, https://adafruit.github.io/arduino-board-index/package_adafruit_index.json ?

kosza

kosza commented on Aug 17, 2017

@kosza
Author

From browser I see the correct json.
The problem is that the Arduino try to download the file from 26000th byte.
It is interesting that your Arduino can download. May be there is a configuration but I didn't find it.
Adafruit's json downloaded correctly. The Range was bytes=0-.

Any ideas?

facchinm

facchinm commented on Aug 17, 2017

@facchinm
Member

Only one idea; maybe there is a stray file from a previous download attempt.
You could try removing that file from Arduino15 folder (on Windows: C:\Users\yourUsername\AppData\Local\Arduino15 , on osx /Users/youruser/Library/Arduino15, on Linux ~/.arduino15 ). In that folder you should find some json files (and their temporary copies and signatures). Remove them all and restart the IDE and let me know if it worked 😉

kosza

kosza commented on Aug 17, 2017

@kosza
Author

You have right. I have deleted the jsons and now IDE downloaded the whole file.
Before I deleted the files the esp's json file was 26000 bytes. So it means the IDE tried to download the new file contents. Why didn't IDE download file from the beginning?

Thanks for your help.

facchinm

facchinm commented on Aug 17, 2017

@facchinm
Member

This is a good question. There is some code here

if (!Files.isRegularFile(outputFile, LinkOption.NOFOLLOW_LINKS) || (Files.size(outputFile) < contribution.getSize())) {
to handle resumed downloads, probably we should add a check to automatically delete the file if the download starts failing.

kosza

kosza commented on Aug 17, 2017

@kosza
Author

I checked DownloadableContributionsDownloader.java, I think it is ok.

// Open file and seek to the end of it
file = new RandomAccessFile(outputFile, "rw");
initialSize = file.length();
file.seek(initialSize);

I think you can remove the following code from line 165 and 186 in Arduino/arduino-core/src/cc/arduino/utils/network/FileDownloader.java
connection.setRequestProperty("Range", "bytes=" + initialSize + "-");
And of course also need to remove line 149 in same.
file.seek(initialSize);

BTW
I did many test. All result were that IDE downloaded the file from 0th byte and replaced the existed file. (I decrease/ingreased the size of the file, I deleted the file.)

facchinm

facchinm commented on Aug 17, 2017

@facchinm
Member

Yep, it enters that bogus condition only in a few very particular conditions... Since jsons are pretty small, I'd download them from 0 everytime to make sure this problem never happens again (instead, I'd leave the feature for bigger files like cores and toolchains)

25 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @cmaglie@ReeceRobinson@per1234@facchinm@Minesbuildlab

        Issue actions

          Boards Manager URLs incorrect HTTP GET Range header field · Issue #6628 · arduino/Arduino