//AllowRead is a pass-through the wrapped object's AllowRead, if present.
973984
func (self *qbsWrapped) AllowRead(pb PBundle) bool {
	allow, ok := self.index.(AllowReader)
	if !ok {
		return true
	}
	return allow.AllowRead(pb)
}
533263
func (te *TxEngine) AcceptReadOnly() error {
	te.beginRequests.Wait()
	te.stateLock.Lock()
	switch te.state {
	case AcceptingReadOnly:
		// Nothing to do
		te.stateLock.Unlock()
		return nil

	case NotServing:
		te.state = AcceptingReadOnly
		te.open()
		te.stateLock.Unlock()
		return nil

	case AcceptingReadAndWrite:
		return te.transitionTo(AcceptingReadOnly)

	case Transitioning:
		te.nextState = AcceptingReadOnly
		te.stateLock.Unlock()
		te.blockUntilEndOfTransition()
		return nil

	default:
		te.stateLock.Unlock()
		return te.unknownStateError()
	}
}
79662
func (o *Object) ReadAt(b []byte, offset int64) (n int, err error) {
	if o == nil {
		return 0, ErrInvalidArgument("Object is nil")
	}

	// Locking.
	o.mutex.Lock()
	defer o.mutex.Unlock()

	// prevErr is error which was saved in previous operation.
	if o.prevErr != nil || o.isClosed {
		return 0, o.prevErr
	}

	// Can only compare offsets to size when size has been set.
	if o.objectInfoSet {
		// If offset is negative than we return io.EOF.
		// If offset is greater than or equal to object size we return io.EOF.
		if (o.objectInfo.Size > -1 && offset >= o.objectInfo.Size) || offset < 0 {
			return 0, io.EOF
		}
	}

	// Create the new readAt request.
	readAtReq := getRequest{
		isReadOp:        true,
		isReadAt:        true,
		DidOffsetChange: true,       // Offset always changes.
		beenRead:        o.beenRead, // Set if this is the first request to try and read.
		Offset:          offset,     // Set the offset.
		Buffer:          b,
	}

	// Alert that this is the first request.
	if !o.isStarted {
		readAtReq.isFirstReq = true
	}

	// Send and receive from the first request.
	response, err := o.doGetRequest(readAtReq)
	if err != nil && err != io.EOF {
		// Save the error.
		o.prevErr = err
		return response.Size, err
	}
	// Bytes read.
	bytesRead := int64(response.Size)
	// There is no valid objectInfo yet
	// 	to compare against for EOF.
	if !o.objectInfoSet {
		// Update the currentOffset.
		o.currOffset += bytesRead
	} else {
		// If this was not the first request update
		// the offsets and compare against objectInfo
		// for EOF.
		oerr := o.setOffset(bytesRead)
		if oerr != nil {
			o.prevErr = oerr
			return response.Size, oerr
		}
	}
	return response.Size, err
}
1147869
func (s *CreateNFSFileShareInput) SetReadOnly(v bool) *CreateNFSFileShareInput {
	s.ReadOnly = &v
	return s
}
598059
func (s *PutObjectInput) SetGrantRead(v string) *PutObjectInput {
	s.GrantRead = &v
	return s
}
980003
func (tscb *TwoStepCircuitBreaker) Allow() (done func(success bool), err error) {
	generation, err := tscb.cb.beforeRequest()
	if err != nil {
		return nil, err
	}

	return func(success bool) {
		tscb.cb.afterRequest(generation, success)
	}, nil
}
559177
func HandleRead(req *ReadRequest, resp *ReadResponse, data []byte) {
	if req.Offset >= int64(len(data)) {
		data = nil
	} else {
		data = data[req.Offset:]
	}
	if len(data) > req.Size {
		data = data[:req.Size]
	}
	n := copy(resp.Data[:req.Size], data)
	resp.Data = resp.Data[:n]
}
392997
func (d *Descriptor) HandleRead(h ReadHandler) {
	if d.value != nil {
		panic("descriptor has been configured with a static value")
	}
	d.props |= CharRead
	// d.secure |= CharRead
	d.rhandler = h
}
1134945
func (s *Event) SetReadOnly(v string) *Event {
	s.ReadOnly = &v
	return s
}
82304
func (f ReadHandlerFunc) ServeRead(req Request, rsp ResponseWriter) {
	f(req, rsp)
}
466937
func (c *Channel) OnRead(f OnReadFunc) {
	// Create a new read handler for this channel.
	// Previous handlers are stopped first.
	handlerStopped := c.readHandler.New()

	// Start the handler goroutine.
	go func() {
		for {
			select {
			case data := <-c.readChan:
				// Call the callback in a new goroutine.
				go func() {
					// Recover panics and log the error.
					defer func() {
						if e := recover(); e != nil {
							log.L.Errorf("glue: panic while calling onRead function: %v\n%s", e, debug.Stack())
						}
					}()

					// Trigger the on read event function.
					f(data)
				}()
			case <-c.s.isClosedChan:
				// Release this goroutine if the socket is closed.
				return
			case <-handlerStopped:
				// Release this goroutine.
				return
			}
		}
	}()
}
1092799
func (a *ACL) AllowOperatorRead() bool {
	switch {
	case a.management:
		return true
	case a.operator == PolicyWrite:
		return true
	case a.operator == PolicyRead:
		return true
	default:
		return false
	}
}
499548
func HTMLReadability(r io.Reader) []byte {
	jr := justext.NewReader(r)

	// TODO: Improve this!
	jr.Stoplist = readabilityStopList
	jr.LengthLow = HTMLReadabilityOptionsValues.LengthLow
	jr.LengthHigh = HTMLReadabilityOptionsValues.LengthHigh
	jr.StopwordsLow = HTMLReadabilityOptionsValues.StopwordsLow
	jr.StopwordsHigh = HTMLReadabilityOptionsValues.StopwordsHigh
	jr.MaxLinkDensity = HTMLReadabilityOptionsValues.MaxLinkDensity
	jr.MaxHeadingDistance = HTMLReadabilityOptionsValues.MaxHeadingDistance

	paragraphSet, err := jr.ReadAll()
	if err != nil {
		log.Println("Justext:", err)
		return nil
	}

	useClasses := strings.SplitN(HTMLReadabilityOptionsValues.ReadabilityUseClasses, ",", 10)

	output := ""
	for _, paragraph := range paragraphSet {
		for _, class := range useClasses {
			if paragraph.CfClass == class {
				output += paragraph.Text + "\n"
			}
		}
	}

	return []byte(output)
}
953884
func RateLimitedReader(r io.Reader, size int, duration time.Duration) io.ReadCloser {
	rl := &rateLimiter{
		action: func(p []byte) (int, error) {
			return r.Read(p)
		},
		limit:     size,
		remaining: size,
		stop:      make(chan bool),
		worker:    make(chan *operation),
	}
	go rl.run(duration)
	return rl
}
1224134
func archiveRead(u *url.URL, tr *tar.Reader) error {
	for {
		header, err := tr.Next()
		if err != nil {
			if err == io.EOF {
				return nil
			}
			return err
		}

		name := filepath.Join(u.Path, header.Name)
		mode := os.FileMode(header.Mode)

		switch header.Typeflag {
		case tar.TypeDir:
			err = os.MkdirAll(name, mode)
		case tar.TypeReg:
			_ = os.MkdirAll(filepath.Dir(name), 0750)

			var f *os.File

			f, err = os.OpenFile(name, os.O_CREATE|os.O_RDWR|os.O_TRUNC, mode)
			if err == nil {
				_, cerr := io.Copy(f, tr)
				err = f.Close()
				if cerr != nil {
					err = cerr
				}
			}
		case tar.TypeSymlink:
			err = os.Symlink(header.Linkname, name)
		}

		// TODO: Uid/Gid may not be meaningful here without some mapping.
		// The other option to consider would be making use of the guest auth user ID.
		// os.Lchown(name, header.Uid, header.Gid)

		if err != nil {
			return err
		}
	}
}
1009357
func (s *UpdateNFSFileShareInput) SetReadOnly(v bool) *UpdateNFSFileShareInput {
	s.ReadOnly = &v
	return s
}
1024596
func (p *PolicyAuthorizer) AgentRead(node string) bool {
	// Check for an exact rule or catch-all
	if rule, ok := getPolicy(node, p.agentRules); ok {
		if allow, recurse := enforce(rule.(string), PolicyRead); !recurse {
			return allow
		}
	}

	// No matching rule, use the parent.
	return p.parent.AgentRead(node)
}