class Amber::Pipe::Pipeline

Overview

This class picks the correct pipeline based on the request and executes it.

Defined in:

amber/pipes/pipeline.cr

Constructors

Class Method Summary

Instance Method Summary

Instance methods inherited from class Amber::Pipe::Base

call(context : HTTP::Server::Context) call

Constructor Detail

def self.new(valve : Symbol = :web) #

[View source]

Class Method Detail

def self.body_inflated_by_server?(request : HTTP::Request) : Bool #

Returns true when HTTP::Server replaced the body of request with a decompressing reader, which Crystal before 1.21.1 does for gzip and deflate bodies with no limit on the inflated size (GHSA-jfq5-c3x6-w7jj). The reader inflates only as it is read, so a request refused at this point has had nothing inflated. Always false in a program built with -Dwithout_zlib, whose server never decompresses.


[View source]
def self.content_encoded?(request : HTTP::Request) : Bool #

Returns true when request carries a compressed body, in either of the two forms a Crystal compiler can hand to Amber:

  • The Content-Encoding header names a coding other than identity, such as gzip or deflate. Every header line and every comma-separated coding is read; empty entries and identity in any case are ignored. Crystal 1.21.1 and later, and crystal-alpha with the GHSA-jfq5-c3x6-w7jj backport, leave the header and the raw body in place.
  • HTTP::Server already wrapped the body in a decompressing reader (see .body_inflated_by_server?). Crystal before 1.21.1 does this for gzip and deflate and deletes Content-Encoding and Content-Length, so the header check alone sees a plain request.
request = HTTP::Request.new("POST", "/", HTTP::Headers{"Content-Encoding" => "gzip"})
Amber::Pipe::Pipeline.content_encoded?(request) # => true

[View source]

Instance Method Detail

def build(valve : Symbol, &) #

Connects pipes to a pipeline to process requests


[View source]
def build_pipeline(pipes, last_pipe : HTTP::Handler | HTTP::Server::Context -> ) #

[View source]
def call(context : HTTP::Server::Context) #
Description copied from class Amber::Pipe::Base

Execution of this handler.


[View source]
def pipeline : Hash(Symbol, Array(HTTP::Handler)) #

[View source]
def plug(pipe : HTTP::Handler) #

[View source]
def prepare_pipelines #

[View source]
def valve : Symbol #

[View source]