
Product
Rust Support in Socket Is Now Generally Available
Socket’s Rust and Cargo support is now generally available, providing dependency analysis and supply chain visibility for Rust projects.
random-access-http
Advanced tools
Continuous reading from a http(s) url using random offsets and lengths
npm install random-access-http
Peers in a distributed system tend to come and go over a short period of time in many common p2p scenarios, especially when you are giving away a file without incentivizing the swarm to seed the file for a long time. There are also an abundance of free cloud hosts that let you host large files over http.
This module provides you random access to a file hosted over http so that it can be used by a client in a distributed system (such as hypercore or hyperdrive) to acquire parts of the file for itself and the other peers in the swarm.
var randomAccessHttp = require('random-access-http')
var file = randomAccessHttp('http://example.com/somefile.mp4')
// Read 10 bytes at an offset of 5
file.read(5, 10, function(err, buffer) {
console.log(buffer)
file.close(function() {
console.log('http keepalive agents and sockets destroyed')
})
})
file will use a keepalive agent to reduce the number http requests needed for the session. When you are done you should call file.close() to destroy the agent.
var file = randomAccessFile(url)Create a new 'file' that reads from the provided url. The url can be either http or https.
file.write(offset, buffer, [callback])Not implemented! Please let me know if you have opinions on how to implement this.
file.read(offset, length, callback)Read a buffer at a specific offset. Callback is called with the buffer read. Currently this will fail if the server returns byte ranges different than what is requested. PRs welcome to expand the flexibility of this method to allow for servers that return fat ranges.
file.close([callback])Close outstanding http keepalive agent sockets.
file.on('open')Emitted when the url has been checked to support range requests and the keep-alive agent has been created.
file.on('close')Emitted after the keepalive agent and its associated sockets have been destroyed.
FAQs
A random access interface for files served over http
The npm package random-access-http receives a total of 10 weekly downloads. As such, random-access-http popularity was classified as not popular.
We found that random-access-http demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket’s Rust and Cargo support is now generally available, providing dependency analysis and supply chain visibility for Rust projects.

Security News
Chrome 144 introduces the Temporal API, a modern approach to date and time handling designed to fix long-standing issues with JavaScript’s Date object.

Research
Five coordinated Chrome extensions enable session hijacking and block security controls across enterprise HR and ERP platforms.