Class IllegalRequestContext

java.lang.Object
org.apache.pekko.http.IllegalRequestContext

public final class IllegalRequestContext extends Object
What is known about a request that failed to parse, at the point where parsing gave up.

Every field is optional because a request can be rejected before that part of it has been read: a request with an unsupported method fails before the request target is seen, and one with an unparsable request target fails before the protocol is seen.

Note that rawRequestTarget is unvalidated, attacker-controlled input, by definition malformed whenever the rejection was caused by the request target itself. It can carry any byte the client chose to send, including CR, LF, NUL and terminal control sequences, so anything that logs or echoes it has to escape it first: written raw into a log it lets a client forge log lines or drive the terminal that displays them, and written raw into a response body it is reflected input. toString escapes it and is safe to log as it is; the field itself is not.

Since:
2.0.0
  • Constructor Details

    • IllegalRequestContext

      public IllegalRequestContext(scala.Option<HttpMethod> method, scala.Option<String> rawRequestTarget, scala.Option<HttpProtocol> protocol)
  • Method Details

    • empty

      public static IllegalRequestContext empty()
      A context that knows nothing about the request, used when no information could be recovered.

      Returns:
      (undocumented)
      Since:
      2.0.0
    • apply

      public static IllegalRequestContext apply(scala.Option<HttpMethod> method, scala.Option<String> rawRequestTarget, scala.Option<HttpProtocol> protocol)
    • method

      public scala.Option<HttpMethod> method()
    • rawRequestTarget

      public scala.Option<String> rawRequestTarget()
    • protocol

      public scala.Option<HttpProtocol> protocol()
    • getMethod

      public Optional<HttpMethod> getMethod()
      Java API

      Returns:
      (undocumented)
      Since:
      2.0.0
    • getRawRequestTarget

      public Optional<String> getRawRequestTarget()
      Java API

      The value is unvalidated, attacker-controlled input and has to be escaped before it is logged or echoed; see the class documentation.

      Returns:
      (undocumented)
      Since:
      2.0.0
    • getProtocol

      public Optional<HttpProtocol> getProtocol()
      Java API

      Returns:
      (undocumented)
      Since:
      2.0.0
    • toString

      public String toString()
      Overrides:
      toString in class Object