Support customizing HTTP method and HTTP body #108
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces the ability to specify a custom HTTP method (e.g.,
POST) and an HTTP body when fetching remote audio streams. Previously, all remote audio requests were hardcoded to use theGETmethod with no body.Motivation & Context:
The primary motivation for this enhancement is to support services like ElevenLabs, which often require
POSTrequests with a JSON body (e.g., to send text for speech synthesis).While ElevenLabs is a specific use case driving this change, the implementation focuses on general extensibility. By allowing customization of the HTTP method and body, we make the
AudioStreamingmodule more versatile and capable of integrating with a wider range of audio streaming APIs that may have requirements beyond simpleGETrequests.Key Changes:
AudioEntryProvider.swift:AudioEntryProvidingprotocol andAudioEntryProviderclass to accepthttpMethod: String?andhttpBody: Data?parameters when creating anAudioEntry.provideAudioSource,source) to propagate these new parameters.GETwith no body, ensuring backward compatibility.RemoteAudioSource.swift:httpMethodandhttpBodyproperties.URLRequestcreation withinstartStreamingAudioDataRequestandstartGetContentLengthRequestto set thehttpMethodandhttpBodyif provided.AudioPlayer.swift:playmethod:These changes provide a more flexible way to interact with remote audio sources. Existing methods remain in place for backward compatibility.