Commit graph

29 commits

Author SHA1 Message Date
Edward Wang
c83242f499 Weaken or remove etags when downstream compression applies
Allow this as an adjustable setting to preserve etag when
(de)compressing. The default is to weaken etags whenever a compression
module applies.
2024-08-16 16:41:51 -07:00
Edward Wang
7003ac34ad Set stale-updating as an explicit CachePhase
This cache phase indicates when we are serving a stale cache hit, but
there is another request currently updating the asset.
2024-08-09 14:30:49 -07:00
Yuchen Wu
32303b9258 Address Rust 1.80 clippy warnings.
Also remove the doc_async_trait cfg since it is no longer viable.
2024-07-26 13:35:13 -07:00
Yuchen Wu
cdefa5c431 Mark the error source from get_http_session()
Although it is implied that fail_to_connect() errors are already caused
by upstream connections, it is more clear for the user's code inside this callback
by marking the error source in this case.
2024-07-12 11:24:29 -07:00
Yuchen Wu
65b1d6c733 Invoke request_body_filter of modules for proxies 2024-07-12 11:24:29 -07:00
Yuchen Wu
62ddb7ebae Move adding ResponseCompression module logic to init_downstream_modules
So that users can override this behavior.
2024-06-28 12:34:25 -07:00
Wladimir Palant
dda7bec58c Added init_downstream_modules phase allowing modules to be set up before startup
Includes-commit: 1bf3d4dfea
Replicated-from: https://github.com/cloudflare/pingora/pull/284
2024-06-28 12:34:25 -07:00
Edward Wang
03bd29044e Always respect_keepalive when releasing http session
When a user calls `release_http_session` on an http Connector, it is
usually implied that they intend to reuse the underlying connection if
possible. Previously for H1 this involved reaching into the H1 client
Session and calling `respect_keepalive`. The new behavior always
respects keepalive as part of releasing the http session, as it was very
easy to overlook this step and unintentionally disable connection reuse
for H1 sessions.
2024-06-28 12:34:25 -07:00
Andrew Hauck
a1f1ad8a43 h2c support 2024-06-21 09:54:09 -07:00
Yuchen Wu
31d7b63ed7 Add new_h1() back
This function turns out to be actually useful for testing and mocking
2024-06-07 15:42:30 -04:00
Yuchen Wu
11863d27a2 Introduce HttpModules to pingora-proxy.
This feature allows to plug in 3rd party extensions with minimal code
required.

The downstream compression logic is now a module.

Add: a new early_request_filter API to fine tune the behavior of the modules.
Add: a few APIs to write the response with these modules enabled. This
should address issues like compression is not applied to custom
responses.
2024-06-07 15:42:30 -04:00
Yuchen Wu
fa071eb506 Refactor Service API: Arc is no longer needed for apps.
This change makes a bit cleaner to use the API. It also allows to
modify the application logic before starting the service.
2024-05-31 11:04:36 -07:00
Zaidoon Abd Al Hadi
026f483712 expose session to cache_hit_filter phase 2024-05-24 10:00:06 -07:00
Yuchen Wu
f38f3b9a38 Add request body filter 2024-05-24 10:00:06 -07:00
Kevin Guthrie
1a6af266a0 cargo fmt 2024-05-10 15:22:37 -07:00
James Munns
880488987c Add Service<HttpProxy<T>> constructor for providing name
Includes-commit: 8727b2466f
Replicated-from: https://github.com/cloudflare/pingora/pull/218
2024-05-10 15:22:37 -07:00
ewang
cfb89c6eb5 Add purge_response callback
Allow generating custom responses to purge requests (requests to
invalidate or delete from the HTTP cache).
2024-05-10 15:22:37 -07:00
yaohuiming
42b0224129 Add async_cleanup() method to ServerApp trait
---
Refactor cleanup functions to use async/await

Includes-commit: 3cd52fee46
Includes-commit: 58946a8d58
Replicated-from: https://github.com/cloudflare/pingora/pull/193
2024-05-10 15:22:37 -07:00
Andrew Hauck
a6bd816f16 Add support for downstream h2 trailers and add an upstream h2 response trailer filter 2024-04-26 12:31:57 -04:00
ewang
3f682ea37f Add cache_not_modified_filter, handle etag/last-modified
This filter allows customizing the `ETag`/`Last-Modified` check to see
if the proxy cache can return 304 Not Modified instead of the full
response.

Also flesh out the `ETag`/`Last-Modified` handling in the base
`not_modified_filter` with `If-None-Match` and `If-Modified-Since`.
2024-04-12 15:30:28 -07:00
Gustav Davidsson
881db9e32c Add/polish some comments 2024-04-05 11:46:20 -07:00
Yuchen Wu
dfcd3d1d9f Fix typos and grammar issues in docs
And other things.

Co-authored-by: DimanNe <causal.consistency@proton.me>
Co-authored-by: Xiaobo Liu <cppcoffee@gmail.com>
Co-authored-by: houseme <housemecn@gmail.com>
Co-authored-by: lilo <luolee.me@gmail.com>
Co-authored-by: Yang He <abruzzi.hraig@gmail.com>
2024-04-05 11:46:20 -07:00
Yuchen Wu
cc32316980 Allow response body to be modified. 2024-04-05 11:46:20 -07:00
battmdpkq
8a84b24ad0 fix some comments
Signed-off-by: battmdpkq <cmaker@163.com>
Replicated-from: https://github.com/cloudflare/pingora/pull/123
Includes-commit: 943bedb281
2024-03-15 14:37:56 -07:00
ewang
20fd391f3e Add server_addr and client_addr to Session 2024-03-15 14:37:56 -07:00
Matthew Gumport
ae8ea771b1 compile and test cleanly with nightly
The vast majority of these are redundant imports.
2024-03-15 14:37:56 -07:00
Yuchen Wu
8160ad1698 Fix typos and grammar issues
Co-authored-by: =?~~~?q?Ren=C3=A9=20Kla=C4=8Dan?= <rene@klacan.sk>
Co-authored-by: 12932 <68835423+12932@users.noreply.github.com>
Co-authored-by: Alessandro <aleferrara1998@gmail.com>
Co-authored-by: InImpasse <40639475+InImpasse@users.noreply.github.com>
Co-authored-by: Paul James Cleary <pauljamescleary@gmail.com>
Co-authored-by: Yang Hau <yuanyanghau@gmail.com>
Co-authored-by: Morpheus <40785143+Muzych@users.noreply.github.com>
Co-authored-by: mobeicanyue <81098819+mobeicanyue@users.noreply.github.com>
Co-authored-by: Twacqwq <69360546+Twacqwq@users.noreply.github.com>
Co-authored-by: Bobby <zkd8907@live.com>
Co-authored-by: Dup4 <lyuzhi.pan@gmail.com>
Co-authored-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
Co-authored-by: Sheldon <1415182877@qq.com>
Co-authored-by: houseme <housemecn@gmail.com>
Co-authored-by: ZhangIvan1 <zhang_ivan1@163.com>
Co-authored-by: GrahamQuan <33834833+GrahamQuan@users.noreply.github.com>
Co-authored-by: =?~~~?q?Cristian=20Paul=20Pe=C3=B1aranda=20Rojas?= <paul@kristianpaul.org>
Co-authored-by: Nathan Sit <nsit.earth@gmail.com>
Co-authored-by: David Lee <67067729+LordMoMA@users.noreply.github.com>
Co-authored-by: Mengliang Su <mengliang.su@shopee.com>
Co-authored-by: =?~~~?q?=EA=B9=80=EC=84=A0=EC=9A=B0?= <seonwoo960000@toss.im>
Co-authored-by: Allen Huang <huangseji@meituan.com>
Co-authored-by: Opacity <70315161+zreren@users.noreply.github.com>
Co-authored-by: cris <sqdcmk@gmail.com>
Co-authored-by: Killian Ye <40255385+ykw1129@users.noreply.github.com>
Co-authored-by: Jiwei-dev <hi.jiwei@gmail.com>
Co-authored-by: Jinfeng Wang <41931794+wjf40390@users.noreply.github.com>
Co-authored-by: Ikko Eltociear Ashimine <eltociear@gmail.com>
2024-03-01 13:47:27 -08:00
ewang
e811382224 Run upstream_response_filter on 304 from upstream cache revalidation
Previously only the response_filter would run on revalidated responses
with no way to process the upstream 304.
Also avoid passing through upstream 304 on revalidate
response_cache_filter errors and instead serve from cache. This
simplifies this edge case because it saves us from needing to check
whether the upstream header filter already ran on the 304 later.
2024-03-01 13:47:27 -08:00
Yuchen Wu
8797329225 Release Pingora version 0.1.0
Co-authored-by: Andrew Hauck <ahauck@cloudflare.com>
Co-authored-by: Edward Wang <ewang@cloudflare.com>
2024-02-27 20:25:44 -08:00