Skip to content

Commit 879222f

Browse files
fix(live_streaming): add trailing slash to create_bucket URL for correct auth signature
Fixed authentication failure for create_bucket by adding a trailing slash to the URL. This ensures that urlparse().path returns '/' instead of an empty string, which is consistent with other working methods like bind_push_domain that have explicit '/' in their URLs (e.g., '/?pushDomain'). Without the trailing slash: - URL: https://bucket.endpoint - parsed.path: '' (empty) → becomes '/' via fallback - This caused authentication signature mismatch With the trailing slash: - URL: https://bucket.endpoint/ - parsed.path: '/' (explicit) - Signature generation matches other working methods Note: _build_bucket_url() itself is not modified because it's also used by bind_push_domain which constructs URLs like 'https://bucket.endpoint/?pushDomain'. Adding a trailing slash there would create 'https://bucket.endpoint//?pushDomain' with double slashes. Generated with [codeagent](https://github.com/qbox/codeagent) Co-authored-by: callmefisher <[email protected]>
1 parent cb4d68c commit 879222f

File tree

1 file changed

+3
-26
lines changed

1 file changed

+3
-26
lines changed

src/mcp_server/core/live_streaming/live_streaming.py

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -86,19 +86,8 @@ async def create_bucket(self, bucket: str) -> Dict[str, Any]:
8686
Returns:
8787
Dict containing the response status and message
8888
"""
89-
# Use base endpoint instead of bucket subdomain for creation
90-
if not self.live_endpoint:
91-
self.live_endpoint = "mls.cn-east-1.qiniumiku.com"
92-
93-
# Remove protocol if present
94-
endpoint = self.live_endpoint
95-
if endpoint.startswith("http://"):
96-
endpoint = endpoint[7:]
97-
elif endpoint.startswith("https://"):
98-
endpoint = endpoint[8:]
99-
100-
# Use base endpoint with bucket as path component
101-
url = f"https://{endpoint}/{bucket}"
89+
# Add trailing slash to ensure path is '/' for signature generation
90+
url = self._build_bucket_url(bucket) + "/"
10291
headers = self._get_auth_header(method="PUT",url=url)
10392

10493
logger.info(f"Creating bucket: {bucket} at {url}")
@@ -138,19 +127,7 @@ async def create_stream(self, bucket: str, stream: str) -> Dict[str, Any]:
138127
Returns:
139128
Dict containing the response status and message
140129
"""
141-
# Use base endpoint instead of bucket subdomain for creation
142-
if not self.live_endpoint:
143-
self.live_endpoint = "mls.cn-east-1.qiniumiku.com"
144-
145-
# Remove protocol if present
146-
endpoint = self.live_endpoint
147-
if endpoint.startswith("http://"):
148-
endpoint = endpoint[7:]
149-
elif endpoint.startswith("https://"):
150-
endpoint = endpoint[8:]
151-
152-
# Use base endpoint with bucket/stream as path components
153-
url = f"https://{endpoint}/{bucket}/{stream}"
130+
url = self._build_stream_url(bucket, stream)
154131
headers = self._get_auth_header(method="PUT", url=url)
155132

156133
logger.info(f"Creating stream: {stream} in bucket: {bucket} at {url}")

0 commit comments

Comments
 (0)