wchen22 commited on
Commit
67df764
·
verified ·
1 Parent(s): 9aa28dc

Upload folder using huggingface_hub

Browse files
Files changed (2) hide show
  1. README.md +3 -1
  2. app.py +4 -1
README.md CHANGED
@@ -47,7 +47,9 @@ Live Space:
47
  include removed-span/char totals, classifier DROP block reasons, and
48
  tool-schema preservation counts when `tools` or `tool_schemas` are supplied.
49
  The HTTP surface accepts `Content-Encoding: gzip` request bodies and gzip
50
- responses for `Accept-Encoding: gzip` or gzipped requests.
 
 
51
  - `/v1/classify` is tokenizer/fallback KEEP-only until a trained KEEP/DROP head
52
  is mounted. `/v1/compress` is rules-first deletion-only compression with
53
  safety receipts. The Space app supports both single `input` requests and
 
47
  include removed-span/char totals, classifier DROP block reasons, and
48
  tool-schema preservation counts when `tools` or `tool_schemas` are supplied.
49
  The HTTP surface accepts `Content-Encoding: gzip` request bodies and gzip
50
+ responses for `Accept-Encoding: gzip` or gzipped requests. If an ingress
51
+ strips the standard content-encoding header, also send
52
+ `X-Touchdown-Content-Encoding: gzip`.
53
  - `/v1/classify` is tokenizer/fallback KEEP-only until a trained KEEP/DROP head
54
  is mounted. `/v1/compress` is rules-first deletion-only compression with
55
  safety receipts. The Space app supports both single `input` requests and
app.py CHANGED
@@ -21,6 +21,7 @@ RULES_VERSION = "hf-space-rules-v0.1.0"
21
  REQUEST_ID_HEADER = "X-Request-ID"
22
  IDEMPOTENCY_KEY_HEADER = "Idempotency-Key"
23
  CONTENT_ENCODING_HEADER = "Content-Encoding"
 
24
  ACCEPT_ENCODING_HEADER = "Accept-Encoding"
25
  GZIP_ENCODING = "gzip"
26
  GZIP_MAGIC = b"\x1f\x8b"
@@ -45,7 +46,8 @@ async def transport_middleware(request: Request, call_next):
45
  try:
46
  body, request_was_gzip = _decode_request_body(
47
  await request.body(),
48
- request.headers.get(CONTENT_ENCODING_HEADER),
 
49
  )
50
  except UnsupportedContentEncoding as exc:
51
  response = Response(
@@ -949,6 +951,7 @@ def health() -> dict[str, Any]:
949
  "transport": {
950
  "request_id_header": REQUEST_ID_HEADER,
951
  "idempotency_key_header": IDEMPOTENCY_KEY_HEADER,
 
952
  "gzip_request_bodies": True,
953
  "gzip_responses": True,
954
  },
 
21
  REQUEST_ID_HEADER = "X-Request-ID"
22
  IDEMPOTENCY_KEY_HEADER = "Idempotency-Key"
23
  CONTENT_ENCODING_HEADER = "Content-Encoding"
24
+ TOUCHDOWN_CONTENT_ENCODING_HEADER = "X-Touchdown-Content-Encoding"
25
  ACCEPT_ENCODING_HEADER = "Accept-Encoding"
26
  GZIP_ENCODING = "gzip"
27
  GZIP_MAGIC = b"\x1f\x8b"
 
46
  try:
47
  body, request_was_gzip = _decode_request_body(
48
  await request.body(),
49
+ request.headers.get(CONTENT_ENCODING_HEADER)
50
+ or request.headers.get(TOUCHDOWN_CONTENT_ENCODING_HEADER),
51
  )
52
  except UnsupportedContentEncoding as exc:
53
  response = Response(
 
951
  "transport": {
952
  "request_id_header": REQUEST_ID_HEADER,
953
  "idempotency_key_header": IDEMPOTENCY_KEY_HEADER,
954
+ "content_encoding_fallback_header": TOUCHDOWN_CONTENT_ENCODING_HEADER,
955
  "gzip_request_bodies": True,
956
  "gzip_responses": True,
957
  },