blob: fac393d82101f7f64ecb1bb6308a075ab8d4e295 [file] [log] [blame]
<!doctype html>
<html lang="en" class="no-js">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<link rel="prev" href="../local-develop-test/">
<link rel="next" href="../file-upload/">
<link rel="icon" href="../../assets/images/favicon.png">
<meta name="generator" content="mkdocs-1.6.0, mkdocs-material-9.5.19">
<title>Http Filter - ServiceComb Java Chassis Developers Guide</title>
<link rel="stylesheet" href="../../assets/stylesheets/main.66ac8b77.min.css">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,300i,400,400i,700,700i%7CRoboto+Mono:400,400i,700,700i&display=fallback">
<style>:root{--md-text-font:"Roboto";--md-code-font:"Roboto Mono"}</style>
<script>__md_scope=new URL("../..",location),__md_hash=e=>[...e].reduce((e,_)=>(e<<5)-e+_.charCodeAt(0),0),__md_get=(e,_=localStorage,t=__md_scope)=>JSON.parse(_.getItem(t.pathname+"."+e)),__md_set=(e,_,t=localStorage,a=__md_scope)=>{try{t.setItem(a.pathname+"."+e,JSON.stringify(_))}catch(e){}}</script>
</head>
<body dir="ltr">
<input class="md-toggle" data-md-toggle="drawer" type="checkbox" id="__drawer" autocomplete="off">
<input class="md-toggle" data-md-toggle="search" type="checkbox" id="__search" autocomplete="off">
<label class="md-overlay" for="__drawer"></label>
<div data-md-component="skip">
<a href="#1-overview" class="md-skip">
Skip to content
</a>
</div>
<div data-md-component="announce">
</div>
<header class="md-header md-header--shadow" data-md-component="header">
<nav class="md-header__inner md-grid" aria-label="Header">
<a href="../.." title="ServiceComb Java Chassis Developers Guide" class="md-header__button md-logo" aria-label="ServiceComb Java Chassis Developers Guide" data-md-component="logo">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 8a3 3 0 0 0 3-3 3 3 0 0 0-3-3 3 3 0 0 0-3 3 3 3 0 0 0 3 3m0 3.54C9.64 9.35 6.5 8 3 8v11c3.5 0 6.64 1.35 9 3.54 2.36-2.19 5.5-3.54 9-3.54V8c-3.5 0-6.64 1.35-9 3.54Z"/></svg>
</a>
<label class="md-header__button md-icon" for="__drawer">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M3 6h18v2H3V6m0 5h18v2H3v-2m0 5h18v2H3v-2Z"/></svg>
</label>
<div class="md-header__title" data-md-component="header-title">
<div class="md-header__ellipsis">
<div class="md-header__topic">
<span class="md-ellipsis">
ServiceComb Java Chassis Developers Guide
</span>
</div>
<div class="md-header__topic" data-md-component="header-topic">
<span class="md-ellipsis">
Http Filter
</span>
</div>
</div>
</div>
<script>var media,input,key,value,palette=__md_get("__palette");if(palette&&palette.color){"(prefers-color-scheme)"===palette.color.media&&(media=matchMedia("(prefers-color-scheme: light)"),input=document.querySelector(media.matches?"[data-md-color-media='(prefers-color-scheme: light)']":"[data-md-color-media='(prefers-color-scheme: dark)']"),palette.color.media=input.getAttribute("data-md-color-media"),palette.color.scheme=input.getAttribute("data-md-color-scheme"),palette.color.primary=input.getAttribute("data-md-color-primary"),palette.color.accent=input.getAttribute("data-md-color-accent"));for([key,value]of Object.entries(palette.color))document.body.setAttribute("data-md-color-"+key,value)}</script>
<label class="md-header__button md-icon" for="__search">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.516 6.516 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5Z"/></svg>
</label>
<div class="md-search" data-md-component="search" role="dialog">
<label class="md-search__overlay" for="__search"></label>
<div class="md-search__inner" role="search">
<form class="md-search__form" name="search">
<input type="text" class="md-search__input" name="query" aria-label="Search" placeholder="Search" autocapitalize="off" autocorrect="off" autocomplete="off" spellcheck="false" data-md-component="search-query" required>
<label class="md-search__icon md-icon" for="__search">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.516 6.516 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5Z"/></svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20 11v2H8l5.5 5.5-1.42 1.42L4.16 12l7.92-7.92L13.5 5.5 8 11h12Z"/></svg>
</label>
<nav class="md-search__options" aria-label="Search">
<button type="reset" class="md-search__icon md-icon" title="Clear" aria-label="Clear" tabindex="-1">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41Z"/></svg>
</button>
</nav>
</form>
<div class="md-search__output">
<div class="md-search__scrollwrap" data-md-scrollfix>
<div class="md-search-result" data-md-component="search-result">
<div class="md-search-result__meta">
Initializing search
</div>
<ol class="md-search-result__list" role="presentation"></ol>
</div>
</div>
</div>
</div>
</div>
</nav>
</header>
<div class="md-container" data-md-component="container">
<main class="md-main" data-md-component="main">
<div class="md-main__inner md-grid">
<div class="md-sidebar md-sidebar--primary" data-md-component="sidebar" data-md-type="navigation" >
<div class="md-sidebar__scrollwrap">
<div class="md-sidebar__inner">
<nav class="md-nav md-nav--primary" aria-label="Navigation" data-md-level="0">
<label class="md-nav__title" for="__drawer">
<a href="../.." title="ServiceComb Java Chassis Developers Guide" class="md-nav__button md-logo" aria-label="ServiceComb Java Chassis Developers Guide" data-md-component="logo">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 8a3 3 0 0 0 3-3 3 3 0 0 0-3-3 3 3 0 0 0-3 3 3 3 0 0 0 3 3m0 3.54C9.64 9.35 6.5 8 3 8v11c3.5 0 6.64 1.35 9 3.54 2.36-2.19 5.5-3.54 9-3.54V8c-3.5 0-6.64 1.35-9 3.54Z"/></svg>
</a>
ServiceComb Java Chassis Developers Guide
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../.." class="md-nav__link">
<span class="md-ellipsis">
Introduction
</span>
</a>
</li>
<li class="md-nav__item md-nav__item--nested">
<input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_2" >
<label class="md-nav__link" for="__nav_2" id="__nav_2_label" tabindex="0">
<span class="md-ellipsis">
Getting Started
</span>
<span class="md-nav__icon md-icon"></span>
</label>
<nav class="md-nav" data-md-level="1" aria-labelledby="__nav_2_label" aria-expanded="false">
<label class="md-nav__title" for="__nav_2">
<span class="md-nav__icon md-icon"></span>
Getting Started
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../../start/terminology/" class="md-nav__link">
<span class="md-ellipsis">
Glossary
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../start/architecture/" class="md-nav__link">
<span class="md-ellipsis">
Architecture
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../start/development-environment/" class="md-nav__link">
<span class="md-ellipsis">
Development environment
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../start/first-sample/" class="md-nav__link">
<span class="md-ellipsis">
Develop the first microservice
</span>
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item md-nav__item--nested">
<input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_3" >
<label class="md-nav__link" for="__nav_3" id="__nav_3_label" tabindex="0">
<span class="md-ellipsis">
Development Service Provider
</span>
<span class="md-nav__icon md-icon"></span>
</label>
<nav class="md-nav" data-md-level="1" aria-labelledby="__nav_3_label" aria-expanded="false">
<label class="md-nav__title" for="__nav_3">
<span class="md-nav__icon md-icon"></span>
Development Service Provider
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../../build-provider/definition/service-definition/" class="md-nav__link">
<span class="md-ellipsis">
Service definition
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../build-provider/define-contract/" class="md-nav__link">
<span class="md-ellipsis">
Service contract definition
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../build-provider/code-first/" class="md-nav__link">
<span class="md-ellipsis">
Implicit API definition
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../build-provider/swagger-annotation/" class="md-nav__link">
<span class="md-ellipsis">
Use Swagger annotations
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../build-provider/springmvc/" class="md-nav__link">
<span class="md-ellipsis">
Develop with SpringMVC
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../build-provider/jaxrs/" class="md-nav__link">
<span class="md-ellipsis">
Develop with JAX-RS
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../build-provider/transparent-rpc/" class="md-nav__link">
<span class="md-ellipsis">
Develop with Transparent RPC
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../build-provider/interface-constraints/" class="md-nav__link">
<span class="md-ellipsis">
Interface definition and data type
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../build-provider/listen-address-and-publish-address/" class="md-nav__link">
<span class="md-ellipsis">
Service listening address and publishing address
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../build-provider/thread-pool/" class="md-nav__link">
<span class="md-ellipsis">
Thread pool
</span>
</a>
</li>
<li class="md-nav__item md-nav__item--nested">
<input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_3_11" >
<label class="md-nav__link" for="__nav_3_11" id="__nav_3_11_label" tabindex="0">
<span class="md-ellipsis">
Service Configuration
</span>
<span class="md-nav__icon md-icon"></span>
</label>
<nav class="md-nav" data-md-level="2" aria-labelledby="__nav_3_11_label" aria-expanded="false">
<label class="md-nav__title" for="__nav_3_11">
<span class="md-nav__icon md-icon"></span>
Service Configuration
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../../build-provider/configuration/ratelimite-strategy/" class="md-nav__link">
<span class="md-ellipsis">
Rate Limiting Policy
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../build-provider/configuration/parameter-validator/" class="md-nav__link">
<span class="md-ellipsis">
Parameter Validator
</span>
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="../../build-provider/bootup/" class="md-nav__link">
<span class="md-ellipsis">
Boot-up Process
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../build-provider/access-log-configuration/" class="md-nav__link">
<span class="md-ellipsis">
Access Log Configuration
</span>
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item md-nav__item--nested">
<input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_4" >
<label class="md-nav__link" for="__nav_4" id="__nav_4_label" tabindex="0">
<span class="md-ellipsis">
Writing Service Consumer
</span>
<span class="md-nav__icon md-icon"></span>
</label>
<nav class="md-nav" data-md-level="1" aria-labelledby="__nav_4_label" aria-expanded="false">
<label class="md-nav__title" for="__nav_4">
<span class="md-nav__icon md-icon"></span>
Writing Service Consumer
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../../build-consumer/common-configuration/" class="md-nav__link">
<span class="md-ellipsis">
Consumer common configuration
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../build-consumer/using-resttemplate/" class="md-nav__link">
<span class="md-ellipsis">
Using Rest Template
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../build-consumer/using-AsyncRestTemplate/" class="md-nav__link">
<span class="md-ellipsis">
Using AsyncRestTemplate
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../build-consumer/develop-consumer-using-rpc/" class="md-nav__link">
<span class="md-ellipsis">
Using with RPC
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../build-consumer/with-contract/" class="md-nav__link">
<span class="md-ellipsis">
Contract
</span>
</a>
</li>
<li class="md-nav__item md-nav__item--nested">
<input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_4_6" >
<label class="md-nav__link" for="__nav_4_6" id="__nav_4_6_label" tabindex="0">
<span class="md-ellipsis">
Invoke control
</span>
<span class="md-nav__icon md-icon"></span>
</label>
<nav class="md-nav" data-md-level="2" aria-labelledby="__nav_4_6_label" aria-expanded="false">
<label class="md-nav__title" for="__nav_4_6">
<span class="md-nav__icon md-icon"></span>
Invoke control
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../../build-consumer/flow-control/" class="md-nav__link">
<span class="md-ellipsis">
Flow Control
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../build-consumer/fault-injection/" class="md-nav__link">
<span class="md-ellipsis">
Fault Injection
</span>
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="../../build-consumer/3rd-party-service-invoke/" class="md-nav__link">
<span class="md-ellipsis">
Invoke 3rd-party REST services
</span>
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item md-nav__item--nested">
<input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_5" >
<label class="md-nav__link" for="__nav_5" id="__nav_5_label" tabindex="0">
<span class="md-ellipsis">
Transports
</span>
<span class="md-nav__icon md-icon"></span>
</label>
<nav class="md-nav" data-md-level="1" aria-labelledby="__nav_5_label" aria-expanded="false">
<label class="md-nav__title" for="__nav_5">
<span class="md-nav__icon md-icon"></span>
Transports
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../../transports/rest-over-servlet/" class="md-nav__link">
<span class="md-ellipsis">
REST over Servlet
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../transports/rest-over-vertx/" class="md-nav__link">
<span class="md-ellipsis">
REST over Vertx
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../transports/highway-rpc/" class="md-nav__link">
<span class="md-ellipsis">
Highway
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../transports/http2/" class="md-nav__link">
<span class="md-ellipsis">
HTTP2
</span>
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item md-nav__item--active md-nav__item--nested">
<input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_6" checked>
<label class="md-nav__link" for="__nav_6" id="__nav_6_label" tabindex="0">
<span class="md-ellipsis">
General Development
</span>
<span class="md-nav__icon md-icon"></span>
</label>
<nav class="md-nav" data-md-level="1" aria-labelledby="__nav_6_label" aria-expanded="true">
<label class="md-nav__title" for="__nav_6">
<span class="md-nav__icon md-icon"></span>
General Development
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../visit-sc/" class="md-nav__link">
<span class="md-ellipsis">
Access Service Center
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../metrics/" class="md-nav__link">
<span class="md-ellipsis">
Metrics
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../microservice-invocation-chain/" class="md-nav__link">
<span class="md-ellipsis">
Microservice invocation chain
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../customized-tracing/" class="md-nav__link">
<span class="md-ellipsis">
Customized-Tracing
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../local-develop-test/" class="md-nav__link">
<span class="md-ellipsis">
Local development and testing
</span>
</a>
</li>
<li class="md-nav__item md-nav__item--active">
<input class="md-nav__toggle md-toggle" type="checkbox" id="__toc">
<a href="./" class="md-nav__link md-nav__link--active">
<span class="md-ellipsis">
Http Filter
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../file-upload/" class="md-nav__link">
<span class="md-ellipsis">
File Uploading
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../file-download/" class="md-nav__link">
<span class="md-ellipsis">
File Downloading
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../reactive/" class="md-nav__link">
<span class="md-ellipsis">
Reactive Programing
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../dnsconfig/" class="md-nav__link">
<span class="md-ellipsis">
DNS Custom Configuration
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../dai-li-she-zhi/" class="md-nav__link">
<span class="md-ellipsis">
Proxy Settings
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../report-framework-version/" class="md-nav__link">
<span class="md-ellipsis">
Report framework version
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../cross-app-invocation/" class="md-nav__link">
<span class="md-ellipsis">
Cross-application invocation
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../secret-field/" class="md-nav__link">
<span class="md-ellipsis">
Customized serialization and deserialization
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../context/" class="md-nav__link">
<span class="md-ellipsis">
Using Context to pass control messages
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../produceprocess/" class="md-nav__link">
<span class="md-ellipsis">
Return value serialization extension
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../CORS/" class="md-nav__link">
<span class="md-ellipsis">
CORS mechanism
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../AlarmEvent/" class="md-nav__link">
<span class="md-ellipsis">
Get fuse and instance isolation alarm event information
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../shutdown/" class="md-nav__link">
<span class="md-ellipsis">
Shutdown gracefully
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../error-handling/" class="md-nav__link">
<span class="md-ellipsis">
Handling exceptions
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../multienvironment/" class="md-nav__link">
<span class="md-ellipsis">
Multi-environment isolation between microservice instances
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../thread-model/" class="md-nav__link">
<span class="md-ellipsis">
Thread Model
</span>
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item md-nav__item--nested">
<input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_7" >
<label class="md-nav__link" for="__nav_7" id="__nav_7_label" tabindex="0">
<span class="md-ellipsis">
Configuration
</span>
<span class="md-nav__icon md-icon"></span>
</label>
<nav class="md-nav" data-md-level="1" aria-labelledby="__nav_7_label" aria-expanded="false">
<label class="md-nav__title" for="__nav_7">
<span class="md-nav__icon md-icon"></span>
Configuration
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../../config/general-config/" class="md-nav__link">
<span class="md-ellipsis">
General config
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../config/inject-config/" class="md-nav__link">
<span class="md-ellipsis">
Configuration injection
</span>
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item md-nav__item--nested">
<input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_8" >
<label class="md-nav__link" for="__nav_8" id="__nav_8_label" tabindex="0">
<span class="md-ellipsis">
Service Capability Open
</span>
<span class="md-nav__icon md-icon"></span>
</label>
<nav class="md-nav" data-md-level="1" aria-labelledby="__nav_8_label" aria-expanded="false">
<label class="md-nav__title" for="__nav_8">
<span class="md-nav__icon md-icon"></span>
Service Capability Open
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../../edge/open-service/" class="md-nav__link">
<span class="md-ellipsis">
Intruductions
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../edge/by-servicecomb-sdk/" class="md-nav__link">
<span class="md-ellipsis">
Using Edge Service
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../edge/nginx/" class="md-nav__link">
<span class="md-ellipsis">
Using confd and Nginx as edge services
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../edge/zuul/" class="md-nav__link">
<span class="md-ellipsis">
Use zuul as edge services
</span>
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item md-nav__item--nested">
<input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_9" >
<label class="md-nav__link" for="__nav_9" id="__nav_9_label" tabindex="0">
<span class="md-ellipsis">
Service Packing and Running
</span>
<span class="md-nav__icon md-icon"></span>
</label>
<nav class="md-nav" data-md-level="1" aria-labelledby="__nav_9_label" aria-expanded="false">
<label class="md-nav__title" for="__nav_9">
<span class="md-nav__icon md-icon"></span>
Service Packing and Running
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../../packaging/standalone/" class="md-nav__link">
<span class="md-ellipsis">
Standalone mode
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../packaging/web-container/" class="md-nav__link">
<span class="md-ellipsis">
WEB container mode
</span>
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item md-nav__item--nested">
<input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_10" >
<label class="md-nav__link" for="__nav_10" id="__nav_10_label" tabindex="0">
<span class="md-ellipsis">
Micro Service Security
</span>
<span class="md-nav__icon md-icon"></span>
</label>
<nav class="md-nav" data-md-level="1" aria-labelledby="__nav_10_label" aria-expanded="false">
<label class="md-nav__title" for="__nav_10">
<span class="md-nav__icon md-icon"></span>
Micro Service Security
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../../security/tls/" class="md-nav__link">
<span class="md-ellipsis">
Using TLS
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../security/rsa/" class="md-nav__link">
<span class="md-ellipsis">
Using RSA certification
</span>
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item md-nav__item--nested">
<input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_11" >
<label class="md-nav__link" for="__nav_11" id="__nav_11_label" tabindex="0">
<span class="md-ellipsis">
Using java chassis in Spring Boot
</span>
<span class="md-nav__icon md-icon"></span>
</label>
<nav class="md-nav" data-md-level="1" aria-labelledby="__nav_11_label" aria-expanded="false">
<label class="md-nav__title" for="__nav_11">
<span class="md-nav__icon md-icon"></span>
Using java chassis in Spring Boot
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../../using-java-chassis-in-spring-boot/using-java-chassis-in-spring-boot/" class="md-nav__link">
<span class="md-ellipsis">
Intruductions
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../using-java-chassis-in-spring-boot/components-for-spring-boot/" class="md-nav__link">
<span class="md-ellipsis">
spring boot starter for java-chassis
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../using-java-chassis-in-spring-boot/java-application/" class="md-nav__link">
<span class="md-ellipsis">
JAVA application development
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../using-java-chassis-in-spring-boot/web-application/" class="md-nav__link">
<span class="md-ellipsis">
Web development method development
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../using-java-chassis-in-spring-boot/diff-between-java-web/" class="md-nav__link">
<span class="md-ellipsis">
The difference between JAVA application method and Web development method
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../using-java-chassis-in-spring-boot/diff-spring-mvc/" class="md-nav__link">
<span class="md-ellipsis">
The difference in Spring MVC mode
</span>
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item md-nav__item--nested">
<input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_12" >
<label class="md-nav__link" for="__nav_12" id="__nav_12_label" tabindex="0">
<span class="md-ellipsis">
Handlers reference
</span>
<span class="md-nav__icon md-icon"></span>
</label>
<nav class="md-nav" data-md-level="1" aria-labelledby="__nav_12_label" aria-expanded="false">
<label class="md-nav__title" for="__nav_12">
<span class="md-nav__icon md-icon"></span>
Handlers reference
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../../references-handlers/intruduction/" class="md-nav__link">
<span class="md-ellipsis">
Intruductions
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../references-handlers/loadbalance/" class="md-nav__link">
<span class="md-ellipsis">
Load Balancing
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../references-handlers/publickey/" class="md-nav__link">
<span class="md-ellipsis">
Public key authentication
</span>
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item md-nav__item--nested">
<input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_13" >
<label class="md-nav__link" for="__nav_13" id="__nav_13_label" tabindex="0">
<span class="md-ellipsis">
FAQ
</span>
<span class="md-nav__icon md-icon"></span>
</label>
<nav class="md-nav" data-md-level="1" aria-labelledby="__nav_13_label" aria-expanded="false">
<label class="md-nav__title" for="__nav_13">
<span class="md-nav__icon md-icon"></span>
FAQ
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../../question-and-answer/question_answer/" class="md-nav__link">
<span class="md-ellipsis">
Q & A
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../question-and-answer/faq/" class="md-nav__link">
<span class="md-ellipsis">
FAQ
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../question-and-answer/interface-compatibility/" class="md-nav__link">
<span class="md-ellipsis">
Micro Service Interface Compatibility FAQ
</span>
</a>
</li>
</ul>
</nav>
</li>
</ul>
</nav>
</div>
</div>
</div>
<div class="md-sidebar md-sidebar--secondary" data-md-component="sidebar" data-md-type="toc" >
<div class="md-sidebar__scrollwrap">
<div class="md-sidebar__inner">
<nav class="md-nav md-nav--secondary" aria-label="Table of contents">
</nav>
</div>
</div>
</div>
<div class="md-content" data-md-component="content">
<article class="md-content__inner md-typeset">
<p>In some scenarios, the service uses http instead of https as the network transmission channel. To prevent the falsification or tampering request, consumer and the producer must be provided a method to signature the http stream.</p>
<p>The signature method is carried using the org.apache.servicecomb.common.rest.filter.HttpClientFilter and org.apache.servicecomb.common.rest.filter.HttpServerFilter interfaces. It is recommended that the http stream related logic use the Filter mechanism here, and the contract The parameter related logic uses the Handler mechanism.</p>
<p>About the use of the Filter interface, please reference [demo-signature] (https://github.com/ServiceComb/ServiceComb-Java-Chassis/tree/master/demo/demo-signature).</p>
<h1 id="1-overview">1 Overview</h1>
<p>The Filter mechanism is loaded using the Java standard SPI mechanism.</p>
<p>Both HttpClientFilter and HttpServerFilter allow multiple loads:</p>
<ul>
<li>
<p>The order of execution between instances is determined by the return value of getOrder</p>
</li>
<li>
<p>If getOrder returns the same value, the corresponding instance order is randomly determined</p>
</li>
</ul>
<p>Whether it is request or response, read the body stream, use getBodyBytes\ (), the return value may be null (such as scenario of getting an invocation), if not null, the corresponding stream length, Obtain through getBodyBytesLength\ (\ ).</p>
<blockquote>
<p><strong><em>Tips</em></strong>:
The beforeSendRequest of HttpClientFilter is executed in the current thread of the interface call, and the afterReceiveResponse is executed in the business thread pool.</p>
<p>The afterReceiveRequest of HttpServerFilter is executed in the business thread pool, beforeSendResponse and beforeSendResponseAsync may be executed in the business thread pool or the network thread pool. Make sure that blocking operations can not occur.</p>
<p>The bottom layer of Java Chassis is an asynchronous framework, with frequent thread switching. When the business extends Filter, if it involves obtaining the thread context through ThreadLocal, the acquisition may be empty. For this scenario, it is recommended to use InhritableThreadLocal instead of ThreadLocal to store data, or to use extended Handler instead of Filter.</p>
</blockquote>
<h1 id="2httpclientfilter">2.HttpClientFilter</h1>
<p>The system has two built-in HttpClientFilter. Note that the order value does not conflict when extending the function:</p>
<ul>
<li>
<p>org.apache.servicecomb.provider.springmvc.reference.RestTemplateCopyHeaderFilter, order value is Integer.MIN_VALUE</p>
</li>
<li>
<p>org.apache.servicecomb.transport.rest.client.http.DefaultHttpClientFilter, order value is Integer.MAX_VALUE</p>
</li>
</ul>
<h2 id="21-prototype">2.1 Prototype</h2>
<pre><code>public interface HttpClientFilter {
int getOrder();
void beforeSendRequest(Invocation invocation, HttpServletRequestEx requestEx);
// if finished, then return a none null response
// if return a null response, then sdk will call next filter.afterReceive
Response afterReceiveResponse(Invocation invocation, HttpServletResponseEx responseEx);
}
</code></pre>
<h2 id="22-beforesendrequest">2.2 beforeSendRequest</h2>
<p>Used to send a request after the stream has been generated
calculate the signature based on url, header, query, and stream
then set to the header \ (requestEx.setHeader).</p>
<p>From the invocation, you can get the various metadata and the object parameters of this call (the stream is generated according to these parameters).</p>
<h2 id="23-afterreceiveresponse">2.3 afterReceiveResponse</h2>
<p>Used to calculate the signature according to the header and the stream after receiving the response from the network, and compare it with the signature in the header. If the signature is incorrect, directly construct a Response.</p>
<p>As a return value, the framework will interrupt calls to other HttpClientFilters as long as it does not return NULL.</p>
<h1 id="3-httpserverfilter">3 HttpServerFilter</h1>
<h2 id="31-prototype">3.1 Prototype</h2>
<pre><code>public interface HttpServerFilter {
int getOrder();
default boolean needCacheRequest(OperationMeta operationMeta) {
return false;
}
// if finished, then return a none null response
// if return a null response, then sdk will call next filter.afterReceiveRequest
Response afterReceiveRequest(Invocation invocation, HttpServletRequestEx requestEx);
// invocation maybe null
void beforeSendResponse(Invocation invocation, HttpServletResponseEx responseEx);
}
</code></pre>
<h2 id="32-needcacherequest">3.2 needCacheRequest</h2>
<p>Unlike HttpClientFilter, the ability to decide whether to cache requests is added.</p>
<p>This is because ServiceComb can not only run in standalone mode but also run in web container (such as Tomcat). In the implementation of a servlet, request stream can only be read once, and does not necessarily support reset (such as Tomcat), RESTful The framework needs to perform deserialization. It needs to read the body stream. The signature logic also needs to read the body stream. If the default processing is used, one of the functions cannot be implemented.</p>
<p>So when running in a web container scenario, all HttpServerFilters, as long as there is a return request that needs to be cached, the body stream will be copied and saved to support repeated reads.</p>
<p>The input parameter is the metadata corresponding to the request, and the service can decide whether the cache request is needed for the request.</p>
<h2 id="33-afterreceiverequest">3.3 afterReceiveRequest</h2>
<p>After receiving the request, the signature is calculated according to the URL, header, query, and code stream, and compared with the signature in the header. If the signature is incorrect, a Response is directly constructed as the return value. As long as the NULL is not returned, the framework will interrupt the other HttpClientFilter Call.</p>
<h2 id="34-beforesendresponse">3.4 beforeSendResponse</h2>
<p>Before sending a response, the signature is calculated according to the header and the stream and set to the header.</p>
<p>Because the invocation has not yet been constructed, the call flow has gone wrong, so the invocation may be null.</p>
</article>
</div>
<script>var target=document.getElementById(location.hash.slice(1));target&&target.name&&(target.checked=target.name.startsWith("__tabbed_"))</script>
</div>
</main>
<footer class="md-footer">
<div class="md-footer-meta md-typeset">
<div class="md-footer-meta__inner md-grid">
<div class="md-copyright">
Made with
<a href="https://squidfunk.github.io/mkdocs-material/" target="_blank" rel="noopener">
Material for MkDocs
</a>
</div>
</div>
</div>
</footer>
</div>
<div class="md-dialog" data-md-component="dialog">
<div class="md-dialog__inner md-typeset"></div>
</div>
<script id="__config" type="application/json">{"base": "../..", "features": [], "search": "../../assets/javascripts/workers/search.b8dbb3d2.min.js", "translations": {"clipboard.copied": "Copied to clipboard", "clipboard.copy": "Copy to clipboard", "search.result.more.one": "1 more on this page", "search.result.more.other": "# more on this page", "search.result.none": "No matching documents", "search.result.one": "1 matching document", "search.result.other": "# matching documents", "search.result.placeholder": "Type to start searching", "search.result.term.missing": "Missing", "select.version": "Select version"}}</script>
<script src="../../assets/javascripts/bundle.dd8806f2.min.js"></script>
</body>
</html>