Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2025 Oracle and/or its affiliates and others.
* Copyright (c) 1997, 2026 Oracle and/or its affiliates and others.
* All rights reserved.
* Copyright 2004 The Apache Software Foundation
*
Expand Down Expand Up @@ -745,6 +745,10 @@ default Supplier<Map<String, String>> getTrailerFields() {
*/
int SC_UPGRADE_REQUIRED = 426;

/**
* Status code (429) indicating that the user has sent too many requests in a given amount of time ("rate limiting").
*/
int SC_TOO_MANY_REQUESTS = 429;
/**
* Status code (500) indicating an error inside the HTTP server which prevented it from fulfilling the request.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright (c) 2026 Contributors to the Eclipse Foundation.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
* version 2 with the GNU Classpath Exception, which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/

package ee.jakarta.servlet.http;

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertNotEquals;

import jakarta.servlet.http.HttpServletResponse;
import org.junit.jupiter.api.Test;

public class HttpServletResponseTooManyRequestsTest {

@Test
public void testScTooManyRequestsValue() {
assertThat(HttpServletResponse.SC_TOO_MANY_REQUESTS, is(429));
}

@Test
public void testScTooManyRequestsIsDistinct() {
assertNotEquals(HttpServletResponse.SC_OK, HttpServletResponse.SC_TOO_MANY_REQUESTS);
assertNotEquals(HttpServletResponse.SC_BAD_REQUEST, HttpServletResponse.SC_TOO_MANY_REQUESTS);
assertNotEquals(HttpServletResponse.SC_UNAUTHORIZED, HttpServletResponse.SC_TOO_MANY_REQUESTS);
assertNotEquals(HttpServletResponse.SC_FORBIDDEN, HttpServletResponse.SC_TOO_MANY_REQUESTS);
}
}