Documentation
¶
Index ¶
- Constants
- func ApplyCookies(req *http.Request, cookies []*http.Cookie)
- func BuildMultipartPayload(fields map[string]string, files []FileField) ([]byte, string, error)
- func BuildMultipartPayloadMulti(fields map[string][]string, files []FileField) ([]byte, string, error)
- func CookiePathCandidates(dbPath string, name string, exts ...string) []string
- func ExtractHTTPErrorDetail(body []byte) string
- func FileBytes(path string) ([]byte, error)
- func LoadCookiesForTracker(ctx context.Context, dbPath string, trackerID string, cookieStore CookieStore, ...) (map[string]string, error)
- func LoadJSONCookieMap(path string) (map[string]string, error)
- func LoadNetscapeCookies(path string, expectedDomain string) ([]*http.Cookie, error)
- func ReadFirstMatching(dir string, patterns ...string) ([]byte, string, error)
- func ReadOptionalFile(path string) string
- func ReadUploadResponseBody(resp *http.Response, successCandidate bool, previewLimit int64) ([]byte, []byte, error)
- func RedactErrorDetail(value string) string
- func ResponseBodyPreview(body []byte, previewLimit int64) []byte
- func WriteFailureArtifact(meta api.PreparedMetadata, dbPath string, tracker string, name string, ...) (string, error)
- type CookieStore
- type FileField
- type HTTPError
Constants ¶
const DefaultResponsePreviewBytes int64 = 64 * 1024
DefaultResponsePreviewBytes bounds tracker response bodies used for failure artifacts and error text.
Variables ¶
This section is empty.
Functions ¶
func ApplyCookies ¶
ApplyCookies adds non-empty cookies to req and ignores nil cookies or blank names and values.
func BuildMultipartPayload ¶
BuildMultipartPayload encodes single-value fields and files as multipart form data and returns the payload with its Content-Type header value.
func BuildMultipartPayloadMulti ¶
func BuildMultipartPayloadMulti(fields map[string][]string, files []FileField) ([]byte, string, error)
BuildMultipartPayloadMulti encodes repeated field values and files as multipart form data and returns the payload with its Content-Type header value.
func CookiePathCandidates ¶
CookiePathCandidates returns cleaned legacy cookie file paths beside dbPath for the supplied tracker name and extensions.
func ExtractHTTPErrorDetail ¶
ExtractHTTPErrorDetail returns a compact, redacted error detail from plain text, HTML, or JSON response bodies.
func FileBytes ¶
FileBytes reads the entire file at path and wraps open/read failures with the trimmed path.
func LoadCookiesForTracker ¶
func LoadCookiesForTracker(ctx context.Context, dbPath string, trackerID string, cookieStore CookieStore, encryptionKey []byte) (map[string]string, error)
LoadCookiesForTracker loads cookies for a tracker from startup cookie files and the database. When both sources are available, database cookies win on conflicts while preserving legacy-file-only cookies. Callers must pass an explicit request-scoped context so cancellation and deadlines are preserved through database cookie reads.
func LoadJSONCookieMap ¶
LoadJSONCookieMap reads a JSON cookie map from path and returns non-empty trimmed names with non-empty values.
func LoadNetscapeCookies ¶
LoadNetscapeCookies reads Netscape-format cookies from path, optionally filtering by expectedDomain. It trims names and domains, preserves cookie values after the value column, and returns an error when no valid cookies match.
func ReadFirstMatching ¶
ReadFirstMatching returns the first readable non-directory file matched by the supplied glob patterns.
func ReadOptionalFile ¶
ReadOptionalFile returns file contents for a non-empty path or an empty string when the path is blank or unreadable.
func ReadUploadResponseBody ¶ added in v0.2.2
func ReadUploadResponseBody(resp *http.Response, successCandidate bool, previewLimit int64) ([]byte, []byte, error)
ReadUploadResponseBody reads a full success-candidate response for parsers and always returns a bounded preview for diagnostics. Non-success responses are read only up to previewLimit.
func RedactErrorDetail ¶
RedactErrorDetail trims value after applying the repository secret redactor.
func ResponseBodyPreview ¶ added in v0.2.2
ResponseBodyPreview returns body unchanged when it fits the limit, otherwise it returns the prefix used for shareable diagnostics.
func WriteFailureArtifact ¶
func WriteFailureArtifact(meta api.PreparedMetadata, dbPath string, tracker string, name string, body []byte, ext string) (string, error)
WriteFailureArtifact stores a tracker failure response under the release temp directory and returns the written path. It returns an empty path when dbPath or the source path is unavailable.
Types ¶
type CookieStore ¶
type CookieStore interface {
GetAllTrackerCookies(ctx context.Context, trackerID string, key []byte) (map[string]string, error)
}
CookieStore interface for dependency injection of cookie storage (database or file-based). This allows tests and different implementations to be plugged in.
type FileField ¶
type FileField struct {
FieldName string
FileName string
Path string
ContentType string
Content []byte
}
FileField describes one file part in a tracker multipart upload. FieldName is the form field; Content is used when present; otherwise Path is read from disk and FileName overrides the filename sent in the part. ContentType is carried for callers that need to retain media-type metadata, but the current builders use Go's default multipart file-part headers.
type HTTPError ¶
type HTTPError struct {
// contains filtered or unexported fields
}
HTTPError is a formatted tracker upload failure with redacted response detail.
func UploadHTTPError ¶
UploadHTTPError formats a tracker upload HTTP failure with redacted response detail extracted from body.
func UploadHTTPErrorWithURL ¶
UploadHTTPErrorWithURL formats a tracker upload HTTP failure with the redacted final URL and response detail.