inproc

package
v1.169.4 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: Apache-2.0 Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package inproc answers a GET against the platform's own routes inside the process, as an anonymous caller on loopback.

A document drawn in the headless renderer loads its references and the served slide runtime from the platform's own origin, and the renderer has no route to the platform: every request it makes is answered by the platform. The tile worker and the PDF export both answer those requests here, so the page gets what a reader's browser would get from the same route and nothing a session would add.

Index

Constants

This section is empty.

Variables

View Source
var ErrTooLarge = errors.New("inproc: the response is larger than the reader takes")

ErrTooLarge is what a Recorder's Write returns once the body would pass its limit, so the route stops writing.

Functions

This section is empty.

Types

type Recorder

type Recorder struct {

	// Body is what the route wrote, never more than the limit.
	Body bytes.Buffer
	// contains filtered or unexported fields
}

Recorder is a response a route writes into in-process.

func NewRecorder

func NewRecorder(limit int64) *Recorder

NewRecorder returns an empty response holding at most limit body bytes.

func (*Recorder) Code

func (r *Recorder) Code() int

Code is the status the route answered, 200 when it wrote none.

func (*Recorder) Header

func (r *Recorder) Header() http.Header

Header is the response header the route sets.

func (*Recorder) Over added in v1.166.4

func (r *Recorder) Over() bool

Over reports whether the route wrote more than the limit.

func (*Recorder) Write

func (r *Recorder) Write(p []byte) (int, error)

Write collects the body, implying 200 when no status was written. A write that would take the body past the limit is refused whole, and the response is marked over.

func (*Recorder) WriteHeader

func (r *Recorder) WriteHeader(status int)

WriteHeader records the first status the route writes. A body the route declares larger than the limit is refused here, before a byte of it is read (#2721), and one it declares within the limit is made room for once.

type Response added in v1.143.0

type Response struct {
	Status int
	Header http.Header
	Body   []byte
}

Response is what a route answered a Read with.

func Read added in v1.143.0

func Read(routes http.Handler, path string, header http.Header, timeout time.Duration, limit int64) (Response, bool)

Read calls routes for one GET of path, passing on the headers of header that change a public route's answer, and returns the response when the route answered 200 or, for a ranged read, 206. It carries no credentials, so only a route that answers anonymously can answer it.

It is marked as the platform's own request, which the public viewer's rate limiter admits without counting (#1791). Counted, every request presents the one loopback address and shares one bucket, and the reference route in front of a document's files ran it dry partway through a document.

The body is held to limit bytes (#2721): a route answering more is stopped where it passes it, and Read reports 413 rather than the part it wrote.

Jump to

Keyboard shortcuts

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