Files
fn_registry/functions/cybersecurity/fetch_http_headers.go
egutierrez bd9383fd82 feat: 16 funciones cybersecurity — análisis, crypto e IO de seguridad
12 funciones puras con implementación real:
HashSHA256, HashMD5, EntropyShannon, IsBase64, IsHex, ExtractURLs,
ParseIPCIDR, IPInRange, NormalizeURL, DetectSQLInjection,
LevenshteinDistance, JaccardSimilarity

4 funciones impuras con implementación real (stdlib):
LookupWhois, ResolveDNS, FetchHTTPHeaders, ScanPortTCP

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 02:23:41 +01:00

28 lines
572 B
Go

package cybersecurity
import (
"fmt"
"net/http"
"time"
)
// FetchHTTPHeaders realiza una solicitud HTTP HEAD a la URL y devuelve los headers de respuesta.
func FetchHTTPHeaders(url string) (map[string][]string, error) {
client := &http.Client{
Timeout: 10 * time.Second,
}
resp, err := client.Head(url)
if err != nil {
return nil, fmt.Errorf("error realizando solicitud HEAD a %s: %w", url, err)
}
defer resp.Body.Close()
headers := make(map[string][]string, len(resp.Header))
for k, v := range resp.Header {
headers[k] = v
}
return headers, nil
}