{"record":{"id":"4bebec906ac851f5","repo":"AlexxIT/go2rtc","slug":"res-status","errorCode":null,"errorMessage":"res.Status","messagePattern":"res\\.Status","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/http/http.go","lineNumber":70,"sourceCode":"\t}\n\n\tif info, ok := prod.(core.Info); ok {\n\t\tinfo.SetProtocol(\"http\")\n\t\tinfo.SetRemoteAddr(req.URL.Host) // TODO: rewrite to net.Conn\n\t\tinfo.SetURL(rawURL)\n\t}\n\n\treturn prod, nil\n}\n\nfunc do(req *http.Request) (core.Producer, error) {\n\tres, err := tcp.Do(req)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif res.StatusCode != http.StatusOK {\n\t\treturn nil, errors.New(res.Status)\n\t}\n\n\t// 1. Guess format from content type\n\tct := res.Header.Get(\"Content-Type\")\n\tif i := strings.IndexByte(ct, ';'); i > 0 {\n\t\tct = ct[:i]\n\t}\n\n\tvar ext string\n\tif i := strings.LastIndexByte(req.URL.Path, '.'); i > 0 {\n\t\text = req.URL.Path[i+1:]\n\t}\n\n\tswitch {\n\tcase ct == \"application/vnd.apple.mpegurl\" || ext == \"m3u8\":\n\t\treturn hls.OpenURL(req.URL, res.Body)\n\tcase ct == \"image/jpeg\":\n\t\treturn image.Open(res)","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/AlexxIT/go2rtc/blob/c245815e75e2a5fd60b4290f12bfc04e55a984d3/internal/http/http.go#L52-L88","documentation":"The HTTP source producer's do() requires the upstream server to answer with HTTP 200 OK. Any other status code causes the library to return an error built from res.Status (e.g. \"404 Not Found\"), aborting the stream. The error message is literally the upstream HTTP status line, surfacing the remote server's response to the caller.","triggerScenarios":"Dialing an HTTP source URL that returns a non-200 response: 401/403 wrong credentials, 404 wrong path, 500 server error, or a redirect that isn't followed to a 200.","commonSituations":"MJPEG/HTTP camera URLs with expired basic-auth credentials, wrong port or path in the stream config, camera web UI returning 302 to a login page, or upstream server temporarily failing.","solutions":["Open the source URL in a browser/curl and confirm it returns 200 with the expected stream","Fix credentials in the URL or config (http://user:pass@host/... or Authorization header)","Correct the URL path/port in the stream source configuration","Check upstream server health; handle redirects by using the final URL directly"],"exampleFix":"// before\nstreams: {cam: \"http://cam.local/wrong/path\"}\n// after\nstreams: {cam: \"http://user:pass@cam.local/mjpeg/1\"}","handlingStrategy":"try-catch","validationCode":"// Pre-check the source URL returns 200 before configuring it\ncurl -f -u user:pass http://cam.local/mjpeg/1 -o /dev/null","typeGuard":null,"tryCatchPattern":"// Go\nprod, err := do(req)\nif err != nil {\n    var status string\n    if strings.Contains(err.Error(), \" \") { // e.g. \"404 Not Found\"\n        status = err.Error()\n    }\n    log.Printf(\"http source failed (%s): %v\", status, err)\n    return err\n}","preventionTips":["Verify camera URLs return 200 before adding them to config","Include credentials in the source URL or headers","Watch for redirects to login pages; use the final URL"],"tags":["http","upstream","status-code","source"],"backgroundTag":"http-non-200-response","analyzedSha":"c245815e75e2a5fd60b4290f12bfc04e55a984d3","analyzedAt":"2026-09-07T11:47:02.965Z","contentChangedAt":"2026-09-07T11:47:02.965Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}