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 theGET
method with no body.Motivation & Context:
The primary motivation for this enhancement is to support services like ElevenLabs, which often require
POST
requests 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
AudioStreaming
module more versatile and capable of integrating with a wider range of audio streaming APIs that may have requirements beyond simpleGET
requests.Key Changes:
AudioEntryProvider.swift
:AudioEntryProviding
protocol andAudioEntryProvider
class to accepthttpMethod: String?
andhttpBody: Data?
parameters when creating anAudioEntry
.provideAudioSource
,source
) to propagate these new parameters.GET
with no body, ensuring backward compatibility.RemoteAudioSource.swift
:httpMethod
andhttpBody
properties.URLRequest
creation withinstartStreamingAudioDataRequest
andstartGetContentLengthRequest
to set thehttpMethod
andhttpBody
if provided.AudioPlayer.swift
:play
method:These changes provide a more flexible way to interact with remote audio sources. Existing methods remain in place for backward compatibility.