[Feature] HTTP HOOK: return detail error in http response
Closed this issue · 2 comments
Return an error from the application or the SRS itself in headers or status codes. This will help you understand why the stream failed to start, either from the application code or the internal state of the SRS.
Example
on_publish "https://example.com/hook/srs/publish";
if stream busy: return status code 100 Continue OR in Headers (the end user will understand that the old stream needs to be stopped)
if error drom application: return response code (proxy?) OR in Headers "status text"
For now, this can only be applied to WHIP
That makes sense; it's worth improving the error message to clearly indicate the root cause.
If success:
< HTTP/1.1 201 Created
< Content-Type: application/sdp
< Location: /rtc/v1/whip/?action=delete&token=77h5570j1&app=live&stream=livestream&session=x209e499:TKxW
< Content-Length: 1376
< Server: SRS/7.0.120(Kai)
<
v=0
......
If request without SDP:
curl 'http://localhost:1985/rtc/v1/whip/?app=live&stream=livestream' -v
< HTTP/1.1 400 Bad Request
< Content-Type: text/plain; charset=utf-8
< Content-Length: 13
< Server: SRS/7.0.120(Kai)
<
5043: RtcInvalidSdp
If request with corrupt SDP:
curl 'http://localhost:1985/rtc/v1/whip/?app=live&stream=livestream' --data-raw $'invalidsdp' -v
< HTTP/1.1 400 Bad Request
< Content-Type: text/plain; charset=utf-8
< Content-Length: 18
< Server: SRS/7.0.120(Kai)
<
5012: RtcSdpDecode
If request with insufficient SDP:
curl 'http://localhost:1985/rtc/v1/whip/?app=live&stream=livestream' --data-raw $'v=0' -v
< HTTP/1.1 400 Bad Request
< Content-Type: text/plain; charset=utf-8
< Content-Length: 21
< Server: SRS/7.0.120(Kai)
<
5018: RtcSdpNegotiate
If publish to a exists stream:
< HTTP/1.1 409 Conflict
< Content-Type: text/plain; charset=utf-8
< Content-Length: 16
< Server: SRS/7.0.120(Kai)
<
1028: StreamBusy
If HTTP hooks or security verify failed:
< HTTP/1.1 401 Unauthorized
< Content-Type: text/plain; charset=utf-8
< Content-Length: 16
< Server: SRS/7.0.120(Kai)
<
1102: SystemAuth
Other errors, for exmaple, RTC disabled:
< HTTP/1.1 500 Internal Server Error
< Content-Type: text/plain; charset=utf-8
< Content-Length: 17
< Server: SRS/7.0.120(Kai)
<
5021: RtcDisabled