org.apache.hc.client5.testing.classic

## Class RandomHandler

- java.lang.Object
- - org.apache.hc.client5.testing.classic.RandomHandler

- All Implemented Interfaces:
    HttpRequestHandler

      public class RandomHandler
      extends Object
      implements HttpRequestHandler

  A handler that generates random data.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `RandomHandler.RandomEntity` An entity that generates random data.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `RandomHandler()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `handle(ClassicHttpRequest request, ClassicHttpResponse response, HttpContext context)` Handles a request by generating random data.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### RandomHandler

          public RandomHandler()

  - ### Method Detail

    - #### handle

          public void handle(ClassicHttpRequest request,
                             ClassicHttpResponse response,
                             HttpContext context)
                      throws HttpException,
                             IOException

      Handles a request by generating random data. The length of the response can be specified in the request URI as a number after the last /. For example /random/whatever/20 will generate 20 random bytes in the printable ASCII range. If the request URI ends with /, a random number of random bytes is generated, but at least one.
      Specified by:
        `handle` in interface `HttpRequestHandler`
      Parameters:
        `request` - the request
        `response` - the response
        `context` - the context
      Throws:
        `HttpException` - in case of a problem
        `IOException` - in case of an IO problem

Copyright © 1999–2021 The Apache Software Foundation. All rights reserved.