{"record":{"id":"efd6b6a29490506c","repo":"valyala/fasthttp","slug":"fasthttp-non-get-request-received","errorCode":null,"errorMessage":"fasthttp: non-get request received","messagePattern":"fasthttp: non-get request received","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"http.go","lineNumber":1369,"sourceCode":"//\n// If MayContinue returns true, the caller must:\n//\n//   - Either send StatusExpectationFailed response if request headers don't\n//     satisfy the caller.\n//   - Or send StatusContinue response before reading request body\n//     with ContinueReadBody.\n//   - Or close the connection.\n//\n// io.EOF is returned if r is closed before reading the first header byte.\nfunc (req *Request) Read(r *bufio.Reader) error {\n\treturn req.ReadLimitBody(r, 0)\n}\n\nconst defaultMaxInMemoryFileSize = 16 * 1024 * 1024\n\n// ErrGetOnly is returned when server expects only GET requests,\n// but some other type of request came (Server.GetOnly option is true).\nvar ErrGetOnly = errors.New(\"fasthttp: non-get request received\")\n\n// ReadLimitBody reads request from the given r, limiting the body size.\n//\n// If maxBodySize > 0 and the body size exceeds maxBodySize,\n// then ErrBodyTooLarge is returned.\n// If maxBodySize <= 0, no limit is applied and the request may consume\n// unbounded memory.\n//\n// RemoveMultipartFormFiles or Reset must be called after\n// reading multipart/form-data request in order to delete temporarily\n// uploaded files.\n//\n// If MayContinue returns true, the caller must:\n//\n//   - Either send StatusExpectationFailed response if request headers don't\n//     satisfy the caller.\n//   - Or send StatusContinue response before reading request body\n//     with ContinueReadBody.","sourceCodeStart":1351,"sourceCodeEnd":1387,"githubUrl":"https://github.com/valyala/fasthttp/blob/c96f600972c6f4a7a30d664257b340ebe9d60124/http.go#L1351-L1387","documentation":"When fasthttp.Server is configured with GetOnly=true, it accepts only GET (and HEAD) requests; any other method causes ReadRequest to fail with ErrGetOnly. This is a deliberate server-side restriction, not a bug.","triggerScenarios":"Client sends POST/PUT/DELETE etc. to a Server created with GetOnly: true; error surfaces during request reading before your Handler runs.","commonSituations":"Health-check or static-asset servers built with GetOnly receiving API calls or form submissions; monitoring POSTing results to a GET-only endpoint; bots POSTing to the server.","solutions":["Remove GetOnly: true from the fasthttp.Server config if non-GET requests are legitimate.","Route non-GET traffic to a different server/port that allows it.","Keep GetOnly and accept the automatic error response; log the method for visibility.","Return a proper 405 in a normal (non-GetOnly) handler if you want custom behavior."],"exampleFix":"// before\nserver := &fasthttp.Server{Handler: h, GetOnly: true}\n// after\nserver := &fasthttp.Server{Handler: h} // handle methods inside h; 405 if needed","handlingStrategy":"try-catch","validationCode":"// client side: only send GET to GetOnly servers\nif req.Method() != \"GET\" && req.Method() != \"HEAD\" {\n    return errors.New(\"endpoint accepts only GET/HEAD\")\n}","typeGuard":null,"tryCatchPattern":"if errors.Is(err, fasthttp.ErrGetOnly) {\n    // endpoint is GET-only; switch method or endpoint\n}","preventionTips":["Don't enable GetOnly unless the server truly serves only static/GET content","Document GET-only endpoints for API consumers","Send health checks with GET"],"tags":["http","fasthttp","method-not-allowed","server-config"],"backgroundTag":"http-method-not-allowed","analyzedSha":"c96f600972c6f4a7a30d664257b340ebe9d60124","analyzedAt":"2026-08-31T22:48:28.265Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}