Przejdź do treści
Biblioteka skilli
Programowanie · Analiza

curl-head-vs-get-header-debugging

/curl-head-vs-get-header-debugging

Naprawia mylące wartości nagłówków HTTP przy debugowaniu przez curl -I: zapytanie HEAD pomija middleware stosowane tylko do GET, więc nagłówki różnią się od zachowania przeglądarki.

Repozytorium
divine-mobile ↗
Licencja
AGPL-3.0
Ostatnia zmiana repozytorium
27.10.2026

Ocena i bezpieczeństwo

100/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść35 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
1
Skrypty
0
Komentarze HTML
0
Adresy URL w SKILL.md
5
Przestarzałość

Brak sygnałów. Repozytorium zmienione 27.10.2026, bez odwołań do wycofanych modeli i API.

Licencja

AGPL-3.0, copyleft: przeróbki udostępniane innym muszą mieć tę samą licencję.

Co robi i kiedy

Naprawia mylące wartości nagłówków HTTP przy debugowaniu przez curl -I: zapytanie HEAD pomija middleware stosowane tylko do GET, więc nagłówki różnią się od zachowania przeglądarki.

Oryginalny opis (EN)

Fix misleading HTTP response header values when debugging with curl -I or curl -sI. Use when: (1) Response headers differ between curl testing and actual browser/client behavior, (2) Cache-Control or other headers show unexpected values despite correct middleware code, (3) Server-side middleware that only applies to GET requests appears to not work when testing with curl -I. The -I flag sends HEAD requests, and middleware that checks for GET method will skip processing, returning handler-level headers instead of middleware-overridden ones.

Jak działa

  1. Problem
  2. Context / Trigger Conditions
  3. Solution
  4. Verification
  5. Example
  6. Notes
Sekcje z nagłówków SKILL.md, w oryginale · 69 linii, 390 słów
Podgląd SKILL.md
---
name: curl-head-vs-get-header-debugging
description: |
  Fix misleading HTTP response header values when debugging with curl -I or curl -sI.
  Use when: (1) Response headers differ between curl testing and actual browser/client behavior,
  (2) Cache-Control or other headers show unexpected values despite correct middleware code,
  (3) Server-side middleware that only applies to GET requests appears to not work when testing
  with curl -I. The -I flag sends HEAD requests, and middleware that checks for GET method will
  skip processing, returning handler-level headers instead of middleware-overridden ones.
author: Claude Code
version: 1.0.0
date: 2026-03-31
---

# curl -I Sends HEAD, Not GET — Header Debugging Trap

## Problem
When debugging HTTP response headers with `curl -I` or `curl -sI`, the response may show
different header values than what actual GET requests receive. This is because `-I` sends
a HEAD request, and server middleware that only processes GET requests will be skipped.

## Context / Trigger Conditions
- Testing cache headers with `curl -sI` and seeing unexpected values
- Middleware that checks `method == GET` before setting headers (common in cache middleware)
- Headers appear correct in automated tests but wrong in manual curl testing
- `Cache-Control`, `Surrogate-Control`, or `Surrogate-Key` values don't match expectations
- Axum/Express/any framework middleware with method guards

## Solution
Use `curl -s -D - -o /dev/null` instead of `curl -I` to get response headers from a **GET** request:

```bash
# WRONG — sends HEAD request, middleware may skip processing
curl -sI https://example.com/api/endpoint

# CORRECT — sends GET request, dumps headers, discards body
curl -s -D - -o /dev/null https://example.com/api/endpoint
```

If you need just specific headers:
```bash
curl -s -D - -o /dev/null https://example.com/api/endpoint | grep -iE 'cache-control|surrogate'
```

## Verification
Compare output from both methods:
```bash
echo "=== HEAD (curl -I) ==="
curl -sI https://example.com/api/endpoint | grep cache-control

echo "=== GET (curl -D) ==="
curl -s -D - -o /dev/null https://example.com/api/endpoint | grep cache-control
```

If the values differ, your middleware has a GET-only guard (which is correct behavior).

## Example
Axum middleware that only sets cache headers for GET requests:
```rust
async fn cache_middleware(request: Request, next: Next) -> Response {
    let method = request.method().clone();
    let mut response = next.run(request).await;

    // HEAD requests skip this — curl -I won't see these headers!
    if method != Method::GET {
        return response;
    }

    response.headers_mut().insert("cache-control", ...);
    response.headers_mut().insert("surrogate-control", ...);
    response
}
```

## Notes
- This is NOT a bug — it's correct behavior. Cache headers should only apply to cacheable GET responses.
- HTTP spec says HEAD responses SHOULD include the same headers as GET, but middleware implementations
  often don't replicate this because HEAD is rarely used by CDNs or browsers for caching decisions.
- Fastly, Cloudflare, and other CDNs send GET requests to origins, so the cache behavior is correct
  even if `curl -I` shows different headers.
- This trap is especially insidious because `curl -I` is the most common way to check headers.

Wersje

W bazie nie ma innych skilli o nazwie curl-head-vs-get-header-debugging.

Identyczna treść występuje jeszcze w 1 innych folderach na GitHubie. Tu pokazujemy jedną, najlepiej ocenioną kopię.

Migawka bazy z 13.11.2026 · wersja paczki 5fb70acc6823 (skrót SHA-256 całej paczki)

Pobrania w ostatnich 30 dniach: 2 · ranking

Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.

Podobne skille

  • 100curl
    Pomaga wykonywać żądania HTTP z wiersza poleceń przez curl, wget i HTTPie: testowanie i debugowanie API REST, uwierzytelnianie, wysyłanie plików i podgląd odpowiedzi.
  • 95curl-cheatsheet
    Podaje polecenia curl: metody HTTP, nagłówki, uwierzytelnianie, wysyłanie JSON i formularzy, pliki, przekierowania i debugowanie.
  • 100http-security-headers
    Weryfikuje i konfiguruje nagłówki bezpieczeństwa odpowiedzi HTTP w serwerze WWW, reverse proxy i middleware aplikacji.
  • 100golang-api-server
    Buduje usługi HTTP, REST API i middleware w Go.
  • 100http-qa
    Przeprowadza weryfikację end-to-end usług HTTP i JSON na działającym serwisie przez curl i jq: sprawdza status, kształt, nagłówki i czas, zapisuje pełny zapis żądań i odpowiedzi jako dowód.
  • 100error-handler-middleware
    Prawdopodobnie pomaga pisać middleware obsługi błędów w aplikacjach backendowych.

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.