{"record":{"id":"a50707c405349806","repo":"TooTallNate/Java-WebSocket","slug":"invalid-request-method-received-s-status-line","errorCode":null,"errorMessage":"Invalid request method received: %s Status line: %s","messagePattern":"Invalid request method received: (.+?) Status line: (.+?)","errorType":"exception","errorClass":"InvalidHandshakeException","httpStatus":null,"severity":"error","filePath":"src/main/java/org/java_websocket/drafts/Draft.java","lineNumber":145,"sourceCode":"    }\n    if (line == null) {\n      throw new IncompleteHandshakeException();\n    }\n    return handshake;\n  }\n\n  /**\n   * Checking the handshake for the role as server\n   *\n   * @param firstLineTokens the token of the first line split as as an string array\n   * @param line            the whole line\n   * @return a handshake\n   */\n  private static HandshakeBuilder translateHandshakeHttpServer(String[] firstLineTokens,\n      String line) throws InvalidHandshakeException {\n    // translating/parsing the request from the CLIENT\n    if (!\"GET\".equalsIgnoreCase(firstLineTokens[0])) {\n      throw new InvalidHandshakeException(String\n          .format(\"Invalid request method received: %s Status line: %s\", firstLineTokens[0], line));\n    }\n    if (!\"HTTP/1.1\".equalsIgnoreCase(firstLineTokens[2])) {\n      throw new InvalidHandshakeException(String\n          .format(\"Invalid status line received: %s Status line: %s\", firstLineTokens[2], line));\n    }\n    ClientHandshakeBuilder clienthandshake = new HandshakeImpl1Client();\n    clienthandshake.setResourceDescriptor(firstLineTokens[1]);\n    return clienthandshake;\n  }\n\n  /**\n   * Checking the handshake for the role as client\n   *\n   * @param firstLineTokens the token of the first line split as as an string array\n   * @param line            the whole line\n   * @return a handshake\n   */","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/TooTallNate/Java-WebSocket/blob/afeacbf8c0f6f6a761c9d9daed8c813dd3b8ed7d/src/main/java/org/java_websocket/drafts/Draft.java#L127-L163","documentation":"This guard fires in Draft.translateHandshakeHttpServer while parsing the server side of a WebSocket opening handshake: the first token of the HTTP request/status line must be the GET method. Receiving any other HTTP method means the request cannot be a valid WebSocket upgrade, so the library rejects the handshake with InvalidHandshakeException. The faulty input is a handshake whose status/request line starts with a method other than GET (e.g. POST, PUT) sent to the server endpoint.","triggerScenarios":"Thrown at src/main/java/org/java_websocket/drafts/Draft.java:145 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure clients connect with an HTTP GET request carrying the WebSocket Upgrade headers, not other HTTP methods","Fix client code (or misconfigured HTTP clients/curl calls) that POSTs or PUTs to the WebSocket endpoint","Check for reverse proxies or gateways rewriting the request method before it reaches the WebSocket server","Log the offending method and status line to identify the non-WebSocket client and reject or redirect it at the HTTP layer"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"afeacbf8c0f6f6a761c9d9daed8c813dd3b8ed7d","analyzedAt":"2026-09-09T14:39:47.546Z","contentChangedAt":"2026-09-09T14:39:47.546Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}