Ağ Araçları
TEKNİK REHBER AĞ ARAÇLARI HTTP DEBUG 2026

curl · wget
http istemcileri.

HTTP hata ayıklama, TLS analizi, timing metrikleri, OTA güncelleme — ağ katmanından uygulama katmanına.

00 curl vs wget — ne zaman hangisi

İkisi de HTTP istemcisidir ama farklı kullanım alanları için optimize edilmiştir.

Özellikcurlwget
Temel felsefeData transfer — stdin/stdout streamDosya indirme — diske yaz
Protokol desteğiHTTP/S, FTP, SFTP, SMTP, SCP, LDAP, +60HTTP/S, FTP
Recursive indirmeHayırEvet (-r)
Resume-C - (manuel)-c (otomatik)
Timing metrikleri-w ile ayrıntılıYok
REST API testMükemmelKısıtlı
Pipe/streamDoğal (stdout)Dosya odaklı
Embedded (busybox)Evet (sınırlı)Evet (iyi)

Kural olarak: API test, debug, TLS analizi → curl. Dosya indirme, mirror, OTA retry → wget.

bash
# Kurulum
apt-get install curl wget

# Versiyon kontrol
curl --version
# curl 8.5.0 (x86_64-pc-linux-gnu) libcurl/8.5.0 OpenSSL/3.0.13
# Protocols: dict file ftp ftps http https ...

wget --version
# GNU Wget 1.21.4

01 curl ile HTTP debug

curl, HTTP bağlantısının her katmanını incelemenizi sağlar — handshake'ten response header'a kadar.

-v / --verbose
Tüm request/response header'larını ve TLS handshake'i göster. > = gönderilen, < = alınan, * = bilgi.
-I / --head
Sadece response header'larını al (HEAD isteği). Body indirme.
-i
Response header + body birlikte döküm. Hem header'ı hem içeriği görmek için.
-o /dev/null
Body'yi çöpe at — sadece header veya timing ilgilendiğinde.
-s / --silent
Progress bar ve hata mesajlarını gizle (scripting için).
-S / --show-error
-s ile birlikte: sessiz ama hataları göster.
-L / --location
Redirect'leri takip et (301, 302). Varsayılan: takip etmez.
-w / --write-out
İstek bittikten sonra format dizgisi yaz. Timing metrikleri için güçlü.
-D dosya
Response header'ları dosyaya yaz.
bash
# Sadece response header'ları göster
curl -I https://example.com
# HTTP/2 200
# content-type: text/html; charset=UTF-8
# server: ECS (nyb/1D2A)
# x-cache: HIT

# Tüm handshake + header + body izle
curl -v https://example.com 2>&1 | head -50

# HTTP status code'u al (sadece)
curl -s -o /dev/null -w "%{http_code}" https://example.com
# 200

# Redirect zincirini izle (-L + -v)
curl -L -v http://example.com 2>&1 | grep '^[*<>]'

# Custom header gönder
curl -H "Accept: application/json" \
     -H "X-Request-ID: test-001" \
     https://api.example.com/status

# Bearer token ile auth
curl -H "Authorization: Bearer eyJhbGci..." \
     https://api.example.com/data

# Basic auth
curl -u "username:password" https://api.example.com/protected

# Cookie gönder
curl -b "session=abc123; lang=tr" https://example.com

# Cookie jar — cookie'leri sakla ve gönder
curl -c cookies.txt -b cookies.txt https://example.com/login

-v çıktısını okumak

curl -v çıktısı
*   Trying 93.184.216.34:443...        ← TCP bağlantısı
* Connected to example.com port 443   ← bağlandı
* TLSv1.3 (OUT), TLS handshake...     ← TLS başladı
* TLSv1.3 (IN), TLS handshake...
* SSL certificate verify ok.          ← sertifika geçerli
> GET / HTTP/2                        ← gönderilen request
> Host: example.com
> User-Agent: curl/8.5.0
> Accept: */*
>                                     ← boş satır = header sonu
< HTTP/2 200                          ← alınan response
< content-type: text/html             ← response header'lar
< server: ECS
<                                     ← boş satır = body başlangıcı
<!doctype html>...

02 curl timing analizi

curl -w ile HTTP isteğinin her fazının ne kadar sürdüğünü ölç. Performans sorununu tam olarak bul.

bash — timing format dosyası
# /tmp/curl-format.txt dosyası oluştur
cat > /tmp/curl-format.txt <<'EOF'
    namelookup:  %{time_namelookup}s
       connect:  %{time_connect}s
    appconnect:  %{time_appconnect}s
   pretransfer:  %{time_pretransfer}s
      redirect:  %{time_redirect}s
 starttransfer:  %{time_starttransfer}s
                ----------
         total:  %{time_total}s
    downloaded:  %{size_download} bytes
     http_code:  %{http_code}
EOF
bash
# Timing ölç
curl -s -o /dev/null -w "@/tmp/curl-format.txt" https://example.com
örnek çıktı
    namelookup:  0.004321s    ← DNS sorgusu
       connect:  0.021543s    ← TCP bağlantısı (namelookup'tan sonra)
    appconnect:  0.089234s    ← TLS handshake tamamlandı
   pretransfer:  0.089301s    ← ilk byte gönderildi
      redirect:  0.000000s    ← redirect yok
 starttransfer:  0.134567s    ← ilk byte alındı (TTFB)
                ----------
         total:  0.145123s    ← toplam süre
    downloaded:  1256 bytes
     http_code:  200

Timing değerlerinin yorumu

time_namelookup
DNS çözümlemesi süresi. Yüksekse DNS sunucusu yavaş veya erişilemez. /etc/hosts veya yerel DNS cache çözüm.
time_connect
TCP three-way handshake süresi. namelookup'tan büyük delta = ağ gecikmesi.
time_appconnect
TLS handshake tamamlanma. connect'ten büyük delta = TLS yavaş (sertifika doğrulama, cipher negotiation).
time_starttransfer
İlk byte alınma zamanı (TTFB — Time To First Byte). appconnect'ten büyük delta = sunucu işleme süresi yavaş.
time_total
Toplam süre. starttransfer'dan büyük delta = indirme/transfer yavaş (büyük response, yavaş ağ).
bash — hızlı inline timing
# Tek satır timing özeti
curl -s -o /dev/null \
  -w "dns:%{time_namelookup} tcp:%{time_connect} tls:%{time_appconnect} ttfb:%{time_starttransfer} total:%{time_total}\n" \
  https://example.com

# Birden fazla URL test et
for url in https://api.example.com/v1/health \
             https://api.example.com/v2/health; do
  echo -n "$url: "
  curl -s -o /dev/null -w "ttfb=%{time_starttransfer}s code=%{http_code}\n" "$url"
done

03 curl ile TLS debug

TLS bağlantı sorunları embedded sistemlerde sık görülür: sertifika zinciri eksik, cipher uyumsuz, saat kaymış.

-k / --insecure
Sertifika doğrulamayı atla. Geliştirme ortamında kullanılır — üretimde asla.
--cacert dosya
Özel CA sertifikası belirt. Self-signed cert veya özel PKI için.
--capath dizin
CA sertifikalarının bulunduğu dizin.
--cert dosya
Client sertifikası (mTLS). PEM formatı.
--key dosya
Client private key (mTLS ile birlikte kullanılır).
--tlsv1.2
TLS 1.2 zorla. Minimum versiyon belirtmek için.
--tlsv1.3
TLS 1.3 zorla.
--tls-max 1.2
Maksimum TLS versiyonu.
--ciphers liste
Kullanılacak cipher suite'leri belirt.
bash
# Sertifika bilgisini göster
curl -v https://example.com 2>&1 | grep '\* SSL\|\* TLS\|\* issuer\|\* subject\|\* expire'

# Self-signed sertifika (geliştirme ortamı)
curl -k https://192.168.1.100:8443/api/status

# Özel CA ile doğrulama
curl --cacert /etc/ssl/custom-ca.pem https://internal.company.com/api

# mTLS — hem sunucu hem client sertifika sunar
curl --cacert ca.pem \
     --cert client.pem \
     --key client-key.pem \
     https://api.example.com/secure

# TLS versiyonu ve cipher test
curl -v --tlsv1.2 --tls-max 1.2 https://example.com 2>&1 | grep TLS

# Sertifika süresini kontrol et
curl -v https://example.com 2>&1 | grep expire
# *  expire date: Apr 15 00:00:00 2026 GMT

# openssl ile daha ayrıntılı TLS analizi
openssl s_client -connect example.com:443 -brief 2>/dev/null
EMBEDDED TLS SORUNLARI

Embedded sistemlerde TLS hatalarının %80'i şu üç nedenden biridir: (1) Sistem saati yanlış — sertifika tarihi doğrulaması başarısız. NTP ile saat senkronizasyonu kritik. (2) CA store eksik — apt-get install ca-certificates çalıştır. (3) Self-signed sertifika — geliştirmede -k kullan ama üretim için gerçek sertifika al.

04 curl ile POST/PUT/DELETE — REST API test

curl, REST API'lerini test etmek için en yaygın kullanılan komut satırı aracıdır.

bash — HTTP metodları
# GET (varsayılan)
curl https://api.example.com/devices

# POST — JSON body
curl -X POST \
     -H "Content-Type: application/json" \
     -d '{"device_id": "dev-001", "status": "online"}' \
     https://api.example.com/devices

# POST — JSON dosyasından oku
curl -X POST \
     -H "Content-Type: application/json" \
     -d "@payload.json" \
     https://api.example.com/devices

# PUT — kaynak güncelle
curl -X PUT \
     -H "Content-Type: application/json" \
     -d '{"status": "offline"}' \
     https://api.example.com/devices/dev-001

# PATCH — kısmi güncelleme
curl -X PATCH \
     -H "Content-Type: application/json" \
     -d '{"firmware": "v2.1.0"}' \
     https://api.example.com/devices/dev-001

# DELETE
curl -X DELETE https://api.example.com/devices/dev-001

# Binary veri gönder (--data-binary)
curl -X POST \
     -H "Content-Type: application/octet-stream" \
     --data-binary "@firmware.bin" \
     https://ota.example.com/upload

Yanıtı işleme

bash
# JSON yanıtı jq ile işle
curl -s https://api.example.com/devices | \
  jq '.devices[] | select(.status == "online") | .id'

# HTTP status kodu + body birlikte al
response=$(curl -s -w "\n%{http_code}" https://api.example.com/health)
body=$(echo "$response" | head -n -1)
code=$(echo "$response" | tail -n 1)
echo "Status: $code, Body: $body"

# Hata kontrolü ile API çağrısı
if ! curl -sf https://api.example.com/status >/dev/null; then
  echo "API erişilemez!"
  exit 1
fi
# -f = HTTP hata kodlarında curl'ü hata ile çıkartır (4xx, 5xx)

05 wget ile recursive ve mirror

wget'in en güçlü olduğu alan: bir web sitesini veya dizini özyinelemeli olarak indirmek.

-r / --recursive
Özyinelemeli indirme — linkler takip edilir.
-l N / --level=N
Derinlik sınırı. -l 0 = sınırsız, -l 1 = sadece tek seviye.
--no-parent
Üst dizine çıkma — sadece hedef URL altındaki dosyaları al.
-m / --mirror
Mirror modu: -r -N -l inf --no-remove-listing birleşimi.
-N / --timestamping
Sunucudaki dosya daha yeniyse indir, değilse atla.
--convert-links
İndirilen HTML'deki linkleri offline okuma için yerel dosyalara dönüştür.
-p / --page-requisites
CSS, JS, resim gibi sayfa bağımlılıklarını da indir.
-A / --accept
Belirli uzantıları indir: -A "*.pdf,*.html"
-R / --reject
Belirli uzantıları reddet.
bash
# Sitenin offline kopyasını al
wget --mirror -p --convert-links -P ./site_mirror https://docs.example.com

# Sadece PDF dosyalarını özyinelemeli indir
wget -r -l 2 -A "*.pdf" --no-parent https://docs.example.com/manuals/

# FTP dizinini indir
wget -r --no-parent ftp://ftp.example.com/releases/

# Belirli dizini indir (sadece firmware dosyaları)
wget -r -l 1 -A "*.bin,*.img" --no-parent \
     https://firmware.example.com/v2.1.0/

# Kullanıcı adı + şifre ile
wget --user=admin --password=secret \
     https://internal.example.com/private/

# Robot.txt'i dikkate alma (dikkatli kullan)
wget -r -e "robots=off" https://example.com

06 wget ile resume ve retry

Büyük firmware dosyaları veya güvenilmez ağ bağlantısı için resume ve retry kritik özelliklerdir.

-c / --continue
Yarıda kalan indirmeyi devam ettir. HTTP Range header kullanır.
--tries=N
Başarısız deneme sayısı. 0 = sonsuz. Varsayılan 20.
--retry-connrefused
Bağlantı reddinde de yeniden dene.
--timeout=N
Toplam timeout süresi (saniye).
--read-timeout=N
Veri okuma timeout (saniye). İndirme donduğunda ne kadar bekle.
--wait=N
İstekler arası bekleme süresi (saniye). Sunucuyu yüklememek için.
-q / --quiet
Progress ve bilgi mesajlarını gizle.
-O dosya
Farklı dosya adıyla kaydet.
-P dizin
İndirme dizinini belirt.
bash
# Güvenilir firmware indirme
wget \
  --tries=5 \
  --timeout=60 \
  --read-timeout=30 \
  -c \
  -O /tmp/firmware_v2.1.bin \
  https://firmware.example.com/v2.1.0/firmware.bin

# İndirme tamamlandıktan sonra checksum doğrula
echo "abc123def456... /tmp/firmware_v2.1.bin" | sha256sum -c

# Bağlantı kesilince otomatik devam et (döngü)
while ! wget -c -q https://firmware.example.com/large_file.bin; do
  echo "Bağlantı kesildi, 10 saniye sonra devam..."
  sleep 10
done

# Resume ile curl
curl -C - -o /tmp/firmware.bin https://firmware.example.com/firmware.bin
# -C - : mevcut dosya boyutundan devam et (otomatik offset)

07 Pratik: embedded HTTP client ve OTA

Embedded sistemlerde OTA (Over-The-Air) güncelleme, wget veya curl ile gerçekleştirilir. Doğru yaz — hatalı OTA cihazı brick'ler.

busybox wget — sınırlılıklar

bash
# busybox wget çok daha sınırlıdır:
# - TLS/HTTPS için libssl gerekir (her busybox binary'sinde yok)
# - --tries, --timeout parametreleri genellikle desteklenmez
# - Progress göstergesi farklı

# busybox wget temel kullanım
wget -O /tmp/update.bin http://ota.example.com/firmware.bin

# HTTPS destekleniyorsa
wget --no-check-certificate -O /tmp/update.bin https://ota.example.com/firmware.bin

# busybox wget desteklemiyor, curl dene
if which curl >/dev/null 2>&1; then
  curl -sf -o /tmp/update.bin "$OTA_URL"
else
  wget -q -O /tmp/update.bin "$OTA_URL"
fi

Güvenli OTA script

bash — /usr/sbin/ota-update.sh
#!/bin/sh
# Güvenli OTA güncelleme scripti
# Checksum doğrulama + atomic apply

set -e

OTA_SERVER="https://ota.example.com"
CURRENT_VERSION=$(cat /etc/firmware-version)
DOWNLOAD_DIR="/tmp/ota"
FIRMWARE_FILE="$DOWNLOAD_DIR/firmware.bin"

mkdir -p "$DOWNLOAD_DIR"

# 1. Güncel versiyon var mı kontrol et
echo "Mevcut versiyon: $CURRENT_VERSION"
LATEST=$(curl -sf --cacert /etc/ssl/ota-ca.pem \
         "$OTA_SERVER/latest-version")

if [ "$LATEST" = "$CURRENT_VERSION" ]; then
  echo "Sistem güncel, güncelleme gerekmez."
  exit 0
fi

echo "Yeni versiyon bulundu: $LATEST — indiriliyor..."

# 2. Firmware indir
if ! curl -sf \
       --cacert /etc/ssl/ota-ca.pem \
       --max-time 300 \
       --retry 3 \
       -o "$FIRMWARE_FILE" \
       "$OTA_SERVER/firmware/$LATEST/firmware.bin"; then
  echo "HATA: Firmware indirilemedi!"
  exit 1
fi

# 3. Checksum doğrula
EXPECTED_SHA=$(curl -sf --cacert /etc/ssl/ota-ca.pem \
               "$OTA_SERVER/firmware/$LATEST/firmware.bin.sha256")

ACTUAL_SHA=$(sha256sum "$FIRMWARE_FILE" | cut -d ' ' -f1)

if [ "$EXPECTED_SHA" != "$ACTUAL_SHA" ]; then
  echo "HATA: Checksum doğrulaması başarısız! Güncelleme iptal edildi."
  rm -f "$FIRMWARE_FILE"
  exit 1
fi

echo "Checksum doğrulandı. Firmware uygulanıyor..."

# 4. Firmware uygula (platforma özgü)
# Örnek: MTD flash yazma
flash_write /dev/mtd3 "$FIRMWARE_FILE" && \
  echo "$LATEST" > /etc/firmware-version

echo "Güncelleme tamamlandı. Yeniden başlatılıyor..."
reboot
OTA GÜVENLİĞİ

OTA güncelleme saldırı yüzeyi büyüktür. Minimum gereksinimler: (1) HTTPS ile şifreli iletim. (2) Sunucu sertifikası doğrulaması — -k asla üretimde kullanma. (3) İndirilen dosyanın SHA-256 veya imza doğrulaması. (4) Güncelleme atomic — başarısız güncelleme cihazı brick etmemeli (dual-bank flash). (5) Rollback mekanizması.

Lightweight curl alternatifleri

bash
# wget2 — modern wget, HTTP/2 destekli, daha az bellek
apt-get install wget2

# httpie — insan dostu HTTP client (Python, büyük footprint)
http GET https://api.example.com/status

# Pure shell HTTPS (bash /dev/tcp + openssl — çok minimal)
# Busybox + openssl varsa:
openssl s_client -quiet -connect api.example.com:443 <<EOF
GET /status HTTP/1.0
Host: api.example.com

EOF