Skip to content

feat: httpStream - #2841

Draft
RohitKushvaha01 wants to merge 2 commits into
Acode-Foundation:mainfrom
RohitKushvaha01:feat/system-http-stream
Draft

feat: httpStream#2841
RohitKushvaha01 wants to merge 2 commits into
Acode-Foundation:mainfrom
RohitKushvaha01:feat/system-http-stream

Conversation

@RohitKushvaha01

@RohitKushvaha01 RohitKushvaha01 commented Aug 31, 2026

Copy link
Copy Markdown
Member

Closes #2827

@greptile-apps

greptile-apps Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds a Cordova-backed HTTP streaming API that exposes native response bytes as a WHATWG ReadableStream, including cancellation and backpressure controls.

  • Adds Android request execution, stream tracking, and lifecycle cleanup.
  • Adds the JavaScript and TypeScript Response-based API.
  • Registers the native source and Internet permission.
  • Adds unit coverage through a local HTTP server and simulated native bridge.
  • Refreshes the package lock and removes the system plugin README.

Confidence Score: 4/5

The PR needs an upper bound for chunkSize before merging because a valid API call can exhaust native memory.

The new bridge passes an unrestricted positive chunkSize into a Java byte-array allocation, and the resulting OutOfMemoryError bypasses the implementation's Exception-based stream failure and cleanup path.

Files Needing Attention: src/plugins/system/android/com/foxdebug/system/StreamHttp.java, src/plugins/system/android/com/foxdebug/system/System.java

Important Files Changed

Filename Overview
src/plugins/system/android/com/foxdebug/system/StreamHttp.java Implements native streaming and lifecycle control, but allows chunkSize to trigger an unbounded native allocation.
src/plugins/system/android/com/foxdebug/system/System.java Adds bridge actions and option parsing; chunkSize is forwarded without a safe upper bound.
src/plugins/system/www/plugin.js Wraps native events in Response and ReadableStream objects with cancellation and byte-based backpressure.
src/plugins/system/plugin.xml Registers the new Android source and Internet permission consistently.
src/plugins/system/system.d.ts Adds the public streaming options and Promise contract.
tests/unit/systemHttpStream.test.js Thoroughly exercises the JavaScript protocol through a simulated native bridge, but does not cover extreme native option values.
package-lock.json Contains a broad lockfile refresh unrelated to the HTTP streaming implementation.

Sequence Diagram

sequenceDiagram
  participant Caller
  participant JS as System.httpStream
  participant Bridge as Cordova bridge
  participant Native as StreamHttp
  participant Server
  Caller->>JS: httpStream(url, options)
  JS->>Bridge: http-stream-start(requestId, url, options)
  Bridge->>Native: Start background request
  Native->>Server: HttpURLConnection request
  Server-->>Native: Status, headers, body bytes
  Native-->>JS: headers event
  JS-->>Caller: Resolve Response
  loop Response data
    Native-->>JS: Base64 data event
    JS-->>Caller: Uint8Array chunk
  end
  JS->>Native: pause/resume/cancel
  Native-->>JS: complete or error
Loading

Reviews (1): Last reviewed commit: "feat: httpStream" | Re-trigger Greptile

: connection.getInputStream();
if (stream == null) {
stream = connection.getInputStream();
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Unbounded native buffer allocation

When a caller supplies a very large positive chunkSize, this line uses it directly for a native byte-array allocation, causing an OutOfMemoryError that bypasses the Exception handler and can terminate the application process. Validate or cap chunkSize before allocating the buffer.

@RohitKushvaha01
RohitKushvaha01 marked this pull request as draft August 31, 2026 08:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs enhancement New feature or request

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

Native HTTP: stream response bodies so plugins can consume SSE / fetch() ReadableStream

1 participant