MCPcopy Create free account
hub / github.com/devploit/nomore403 / rawRequest

Function rawRequest

cmd/api.go:482–586  ·  view source on GitHub ↗
(method, uri string, requestTarget string, headers []header, body string, timeout int)

Source from the content-addressed store, hash-verified

480}
481
482func rawRequest(method, uri string, requestTarget string, headers []header, body string, timeout int) (ResponseInfo, error) {
483 parsedURL, err := url.Parse(uri)
484 if err != nil || parsedURL == nil || parsedURL.Scheme == "" || parsedURL.Host == "" {
485 parsedURL, err = parseRawURL(uri)
486 if err != nil {
487 return ResponseInfo{}, err
488 }
489 }
490
491 addr := parsedURL.Host
492 if parsedURL.Port() == "" {
493 port := "80"
494 if parsedURL.Scheme == "https" {
495 port = "443"
496 }
497 addr = net.JoinHostPort(parsedURL.Hostname(), port)
498 }
499
500 dialer := &net.Dialer{Timeout: time.Duration(timeout) * time.Millisecond}
501 var conn net.Conn
502 if parsedURL.Scheme == "https" {
503 conn, err = tls.DialWithDialer(dialer, "tcp", addr, &tls.Config{
504 InsecureSkipVerify: true,
505 ServerName: parsedURL.Hostname(),
506 })
507 } else {
508 conn, err = dialer.Dial("tcp", addr)
509 }
510 if err != nil {
511 return ResponseInfo{}, err
512 }
513 defer func() {
514 _ = conn.Close()
515 }()
516 _ = conn.SetDeadline(time.Now().Add(time.Duration(timeout) * time.Millisecond))
517
518 if requestTarget == "" {
519 requestTarget = rawRequestTarget(uri)
520 }
521
522 hasHost := false
523 hasConnection := false
524 hasContentLength := false
525 var builder strings.Builder
526 builder.WriteString(method)
527 builder.WriteString(" ")
528 builder.WriteString(requestTarget)
529 builder.WriteString(" HTTP/1.1\r\n")
530 for _, h := range headers {
531 if strings.EqualFold(h.key, "Host") {
532 hasHost = true
533 }
534 if strings.EqualFold(h.key, "Connection") {
535 hasConnection = true
536 }
537 if strings.EqualFold(h.key, "Content-Length") {
538 hasContentLength = true
539 }

Callers 6

requestBodyFunction · 0.85
executeReplayFunction · 0.85
setRawTechniqueBaselineFunction · 0.85
requestRawDuplicatesFunction · 0.85
requestRawAuthorityFunction · 0.85
requestRawDesyncFunction · 0.85

Calls 3

parseRawURLFunction · 0.85
rawRequestTargetFunction · 0.85
captureBodySignatureFunction · 0.85

Tested by

no test coverage detected