Documentation ¶
Index ¶
- Constants
- Variables
- func BindAdapter(s Adapter, names ...string)
- func Server(query string) (string, string, error)
- type Adapter
- type Client
- type FetchError
- type Record
- type Request
- type Response
- func (res *Response) Adapter() Adapter
- func (res *Response) Checksum() string
- func (res *Response) ContentType() string
- func (res *Response) DetectCharset()
- func (res *Response) DetectContentType(ct string)
- func (res *Response) Encoding() (encoding.Encoding, error)
- func (res *Response) Header() http.Header
- func (res *Response) Reader() (io.Reader, error)
- func (res *Response) String() string
- func (res *Response) Text() ([]byte, error)
- func (res *Response) WriteMIME(w io.Writer) error
Constants ¶
const ( // DefaultTimeout sets the maximum lifetime of whois requests. DefaultTimeout = 30 * time.Second // DefaultReadLimit sets the maximum bytes a client will attempt to read from a connection. DefaultReadLimit = 1 << 20 // 1 MB )
const (
// IANA is the default whois server for TLDs.
IANA = "whois.iana.org"
)
Variables ¶
var DefaultAdapter = &defaultAdapter{}
DefaultAdapter is the default Adapter for most whois servers.
var DefaultClient = NewClient(DefaultTimeout)
DefaultClient represents a shared whois client with a default timeout, HTTP transport, and dialer.
var ErrURLNotSupported = errors.New("URL not supported")
ErrURLNotSupported is returned when an adapter cannot support a given request.
Functions ¶
func BindAdapter ¶
BindAdapter globally associates an Adapter with given hostname(s).
Types ¶
type Adapter ¶
type Adapter interface { // Prepare performs any server-specific modifications of the Request. Prepare(*Request) error // Text returns the UTF-8 text of the Response body, stripping off any // excess data, (e.g. HTML) from a web response. Text(*Response) ([]byte, error) }
Adapter contains server-specific code for retrieving and parsing whois data.
type Client ¶
type Client struct { Dial func(string, string) (net.Conn, error) // Deprecated, use DialContext instead DialContext func(context.Context, string, string) (net.Conn, error) // Only used for port 43 (whois) requests, not HTTP(S) HTTPClient *http.Client // If nil, http.DefaultClient will be used Timeout time.Duration // Deprecated (use a Context instead) }
Client represents a whois client. It contains an http.Client, for executing some whois Requests.
type FetchError ¶
FetchError reports the underlying error and includes the target host of the fetch operation.
func (*FetchError) Error ¶
func (f *FetchError) Error() string
Error implements the error interface.
type Request ¶
Request represents a whois request.
func NewRequest ¶
NewRequest returns a prepared Request ready to fetch. On error, returns a nil Request and the error.
type Response ¶
type Response struct { // Query and Host are copied from the Request. Query string Host string // FetchedAt is the date and time the response was fetched from the server. FetchedAt time.Time // MediaType and Charset hold the MIME-type and character set of the response body. MediaType string Charset string // Body contains the raw bytes of the network response (minus HTTP headers). Body []byte }
Response represents a whois response from a server.
func NewResponse ¶
NewResponse initializes a new whois response.
func ReadMIMEFile ¶
ReadMIMEFile opens and reads a response MIME file at path. Returns any errors.
func (*Response) ContentType ¶
ContentType returns an RFC 2045 compatible internet media type string.
func (*Response) DetectCharset ¶
func (res *Response) DetectCharset()
DetectCharset returns best guess for the reesponse body character set.
func (*Response) DetectContentType ¶
DetectContentType detects and sets the response content type and charset.
func (*Response) String ¶
String returns a string representation of the response text. Returns an empty string if an error occurs.