mirror of
https://github.com/aler9/gortsplib
synced 2025-10-08 16:40:09 +08:00
add status codes
This commit is contained in:
@@ -8,7 +8,7 @@ import (
|
||||
|
||||
// Response is a RTSP response.
|
||||
type Response struct {
|
||||
StatusCode int
|
||||
StatusCode StatusCode
|
||||
Status string
|
||||
Header Header
|
||||
Content []byte
|
||||
@@ -34,10 +34,10 @@ func readResponse(br *bufio.Reader) (*Response, error) {
|
||||
statusCodeStr := string(byts[:len(byts)-1])
|
||||
|
||||
statusCode64, err := strconv.ParseInt(statusCodeStr, 10, 32)
|
||||
res.StatusCode = int(statusCode64)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to parse status code")
|
||||
}
|
||||
res.StatusCode = StatusCode(statusCode64)
|
||||
|
||||
byts, err = readBytesLimited(br, '\r', 255)
|
||||
if err != nil {
|
||||
|
@@ -21,7 +21,7 @@ var casesResponse = []struct {
|
||||
"\r\n",
|
||||
),
|
||||
&Response{
|
||||
StatusCode: 200,
|
||||
StatusCode: StatusOK,
|
||||
Status: "OK",
|
||||
Header: Header{
|
||||
"CSeq": []string{"1"},
|
||||
@@ -40,7 +40,7 @@ var casesResponse = []struct {
|
||||
"\r\n",
|
||||
),
|
||||
&Response{
|
||||
StatusCode: 200,
|
||||
StatusCode: StatusOK,
|
||||
Status: "OK",
|
||||
Header: Header{
|
||||
"CSeq": []string{"2"},
|
||||
|
60
statuscodes.go
Normal file
60
statuscodes.go
Normal file
@@ -0,0 +1,60 @@
|
||||
package gortsplib
|
||||
|
||||
// StatusCode is a RTSP response status code.
|
||||
type StatusCode int
|
||||
|
||||
// https://tools.ietf.org/html/rfc7826#section-17
|
||||
const (
|
||||
StatusContinue StatusCode = 100
|
||||
|
||||
StatusOK = 200
|
||||
|
||||
StatusMovedPermanently = 301
|
||||
StatusFound = 302
|
||||
StatusSeeOther = 303
|
||||
StatusNotModified = 304
|
||||
StatusUseProxy = 305
|
||||
|
||||
StatusBadRequest = 400
|
||||
StatusUnauthorized = 401
|
||||
StatusPaymentRequired = 402
|
||||
StatusForbidden = 403
|
||||
StatusNotFound = 404
|
||||
StatusMethodNotAllowed = 405
|
||||
StatusNotAcceptable = 406
|
||||
StatusProxyAuthRequired = 407
|
||||
StatusRequestTimeout = 408
|
||||
StatusGone = 410
|
||||
StatusPreconditionFailed = 412
|
||||
StatusRequestEntityTooLarge = 413
|
||||
StatusRequestURITooLong = 414
|
||||
StatusUnsupportedMediaType = 415
|
||||
StatusParameterNotUnderstood = 451
|
||||
StatusIllegalConferenceIdentifier = 452
|
||||
StatusNotEnoughBandwidth = 453
|
||||
StatusSessionNotFound = 454
|
||||
StatusMethodNotValidInThisState = 455
|
||||
StatusHeaderFieldNotValidForResource = 456
|
||||
StatusInvalidRange = 457
|
||||
StatusParameterIsReadOnly = 458
|
||||
StatusAggregateOperationNotAllowed = 459
|
||||
StatusOnlyAggregateOperationAllowed = 460
|
||||
StatusUnsupportedTransport = 461
|
||||
StatusDestinationUnreachable = 462
|
||||
StatusDestinationProhibited = 463
|
||||
StatusDataTransportNotReadyYet = 464
|
||||
StatusNotificationReasonUnknown = 465
|
||||
StatusKeyManagementError = 466
|
||||
StatusConnectionAuthorizationRequired = 470
|
||||
StatusConnectionCredentialsNotAccepted = 471
|
||||
StatusFailureToEstablishSecureConnection = 472
|
||||
|
||||
StatusInternalServerError = 500
|
||||
StatusNotImplemented = 501
|
||||
StatusBadGateway = 502
|
||||
StatusServiceUnavailable = 503
|
||||
StatusGatewayTimeout = 504
|
||||
StatusRTSPVersionNotSupported = 505
|
||||
StatusOptionNotSupported = 551
|
||||
StatusProxyUnavailable = 553
|
||||
)
|
Reference in New Issue
Block a user