http

package
v3.11.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 8, 2026 License: MIT, Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package http exposes an httpx-shaped HTTP client for nuclei JavaScript templates (require('nuclei/http')).

Dial, TLS, and host-policy reuse the scan's fastdialer via protocolstate. The YAML httpclientpool is not used here to avoid an import cycle with the JS compiler; connection reuse still goes through fastdialer.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NegotiateNTLM

func NegotiateNTLM() string

NegotiateNTLM returns a base64 Type-1 NTLM negotiate message suitable for an Authorization header (without the "NTLM " prefix). @example ```javascript const http = require('nuclei/http'); const client = new http.Client(); client.SetHeader('Authorization', 'NTLM ' + http.NegotiateNTLM()); const resp = client.Get('https://exchange.acme.local/ews/'); ```

func NewClient

func NewClient(call goja.ConstructorCall, runtime *goja.Runtime) *goja.Object

NewClient constructs a Client with httpx-like defaults (follow redirects, cookie jar enabled).

Constructor: constructor(public options?: Options)

Types

type Client

type Client struct {
	TimeoutSeconds  int
	FollowRedirects bool
	MaxRedirects    int
	MaxBodyBytes    int
	DisableCookie   bool
	// contains filtered or unexported fields
}

Client is an HTTP client for nuclei JS templates. @example ```javascript const http = require('nuclei/http'); const client = new http.Client(); const resp = client.Get('https://example.com'); log(resp.StatusCode + ' ' + resp.Body); ```

func (*Client) Get

func (c *Client) Get(ctx context.Context, rawURL string) (*Response, error)

Get performs an HTTP GET. @example ```javascript const http = require('nuclei/http'); const client = new http.Client(); const resp = client.Get('https://example.com'); ```

func (*Client) Head

func (c *Client) Head(ctx context.Context, rawURL string) (*Response, error)

Head performs an HTTP HEAD. @example ```javascript const http = require('nuclei/http'); const client = new http.Client(); const resp = client.Head('https://example.com'); ```

func (*Client) Post

func (c *Client) Post(ctx context.Context, rawURL, body string) (*Response, error)

Post performs an HTTP POST with the given body string. @example ```javascript const http = require('nuclei/http'); const client = new http.Client(); const resp = client.Post('https://example.com/login', 'user=a&pass=b'); ```

func (*Client) Request

func (c *Client) Request(ctx context.Context, method, rawURL, body string) (*Response, error)

Request performs an HTTP request with the given method and optional body. @example ```javascript const http = require('nuclei/http'); const client = new http.Client(); const resp = client.Request('PUT', 'https://example.com/item', '{"a":1}'); ```

func (*Client) SetHeader

func (c *Client) SetHeader(key, value string)

SetHeader sets a default request header on the client. @example ```javascript const http = require('nuclei/http'); const client = new http.Client(); client.SetHeader('User-Agent', 'nuclei'); ```

type NTLMInfo

type NTLMInfo struct {
	MessageType         int
	TargetName          string
	NetBIOSDomainName   string
	NetBIOSComputerName string
	DNSDomainName       string
	DNSComputerName     string
	DNSTreeName         string
	ProductVersion      string
	Timestamp           uint64
	UnixTimestamp       int64
}

NTLMInfo holds fields decoded from an NTLM Type-2 challenge (Burp ntlm-challenge-decoder / nmap-style AV pairs). @example ```javascript const http = require('nuclei/http'); const resp = http.Get('https://exchange.acme.local/ews/'); const info = http.DecodeNTLM(resp.GetHeader('WWW-Authenticate')); log(info.DNSComputerName + ' ' + info.DNSDomainName); ```

func DecodeNTLM

func DecodeNTLM(blob string) (*NTLMInfo, error)

DecodeNTLM decodes an NTLM SSP blob from a WWW-Authenticate / Authorization header value or raw base64. Accepts prefixes "NTLM " and "Negotiate ". Only Type-2 (challenge) messages populate TargetInfo fields. @example ```javascript const http = require('nuclei/http'); const info = http.DecodeNTLM('NTLM TlRMTVNTUAACAAAA...'); ```

type Options

type Options struct {
	// TimeoutSeconds is the overall request timeout. 0 uses 30s.
	TimeoutSeconds int
	// MaxRedirects caps redirects when following (default 10).
	MaxRedirects int
	// MaxBodyBytes caps response body reads (default 5MiB). 0 uses default.
	MaxBodyBytes int
	// DisableRedirects turns off redirect following (on by default).
	DisableRedirects bool
	// DisableCookie disables the per-client cookie jar.
	DisableCookie bool
}

Options configures a Client. All fields are optional. @example ```javascript const http = require('nuclei/http'); const opts = new http.Options(); opts.TimeoutSeconds = 15; opts.MaxRedirects = 5; const client = new http.Client(opts); ```

type Response

type Response struct {
	StatusCode int
	URL        string
	Body       string
	Headers    map[string]string
	// contains filtered or unexported fields
}

Response is an HTTP response returned by Client methods. @example ```javascript const http = require('nuclei/http'); const resp = http.Get('https://example.com'); log(resp.StatusCode); log(resp.GetHeader('Content-Type')); ```

func Get

func Get(ctx context.Context, rawURL string) (*Response, error)

Get is a package-level GET using a default client (redirects + cookies on). @example ```javascript const http = require('nuclei/http'); const resp = http.Get('https://example.com'); ```

func Head(ctx context.Context, rawURL string) (*Response, error)

Head is a package-level HEAD using a default client. @example ```javascript const http = require('nuclei/http'); const resp = http.Head('https://example.com'); ```

func Post

func Post(ctx context.Context, rawURL, body string) (*Response, error)

Post is a package-level POST using a default client. @example ```javascript const http = require('nuclei/http'); const resp = http.Post('https://example.com/login', 'user=a&pass=b'); ```

func Request

func Request(ctx context.Context, method, rawURL, body string) (*Response, error)

Request is a package-level request using a default client. @example ```javascript const http = require('nuclei/http'); const resp = http.Request('OPTIONS', 'https://example.com', ”); ```

func (*Response) GetHeader

func (r *Response) GetHeader(name string) string

GetHeader returns the first value for a header (case-insensitive), or "". @example ```javascript const http = require('nuclei/http'); const resp = http.Get('https://example.com'); const ct = resp.GetHeader('content-type'); ```

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL