【问题标题】:Is the Range property in Java for HttpURLConnections inclusive or exclusive?Java 中 HttpURLConnections 的 Range 属性是包含还是不包含?
【发布时间】:2016-03-17 15:24:56
【问题描述】:

我正在使用 Range 从网上抓取对象,如下所示:

HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
urlConnection.setRequestProperty("Range", "bytes=0-1000");

// Parallel in different thread

HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
urlConnection.setRequestProperty("Range", "bytes=1000-2000");

// More code that actually collects the data

这是两次抓取第 1000 个字节吗?还是上限排他?

【问题讨论】:

    标签: java networking range httpconnection


    【解决方案1】:

    职位包括在内。

    https://www.rfc-editor.org/rfc/rfc7233#section-2.1

    byte-range-spec 中的 first-byte-pos 值给出了范围内第一个字节的字节偏移量。 last-byte-pos 值给出了范围内最后一个字节的字节偏移量; 也就是说,指定的字节位置包括在内。字节偏移量从零开始。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-02-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-06
      • 2014-02-06
      • 2023-04-02
      • 1970-01-01
      相关资源
      最近更新 更多