bd9383fd82
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>
28 lines
572 B
Go
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
|
|
}
|