Normalize Header

This module provides an example of Normalize Header.

class callouts.python.extproc.example.normalize_header.service_callout_example.CalloutServerExample(*args: Any, **kwargs: Any)[source]

Bases: CalloutServer

Example header normalization callout server.

For request header callouts we check the host header and create a new HTTP header (client-device-type) to shard requests based on device.

add_device_type_header(headers: envoy.service.ext_proc.v3.external_processor_pb2.HttpHeaders) envoy.service.ext_proc.v3.external_processor_pb2.HeadersResponse[source]

Generate a client-device-type header response.

Parameters:

headers – Current headers presented in the callout.

Returns:

The constructed HeadersResponse object.

on_request_headers(headers: envoy.service.ext_proc.v3.external_processor_pb2.HttpHeaders, context: ServicerContext) envoy.service.ext_proc.v3.external_processor_pb2.HeadersResponse[source]

Custom processor on request headers.

Parameters:
  • headers (service_pb2.HttpHeaders) – The HTTP headers received in the request.

  • context (ServicerContext) – The context object for the gRPC service.

Returns:

The response containing the mutations to be applied to the request headers.

Return type:

service_pb2.HeadersResponse

callouts.python.extproc.example.normalize_header.service_callout_example.get_device_type(host_value: str) str[source]

Determine device type based on user agent.