<commit_before>// Copyright (c) 2013, <NAME>
// For more information, see the LICENSE file

package spdy

import (
	"bufio"
	"bytes"
	"errors"
	"fmt"
	"github.com/DanielMorsing/spdy/framing"
	"io"
	"io/ioutil"
	"log"
	"net/http"
	"net/url"
	"sync"
)

// stream represents a spdy stream within a session
type stream struct {
	// the stream id for this stream
	id framing.StreamId

	// window size
	sendWindow    uint32
	receiveWindow uint32
	windowOffset  uint32
	priority      uint8
	reset         chan struct{}
	recvData      chan struct{}
	windowUpdate  chan struct{}
	session       *session
	receivedFin   bool
	closed        bool
	buf           bytes.Buffer
	
	// channel to communicate with outframer.
	ofchan chan struct{}

	// mutex to protect the window variables
	mu sync.Mutex
}

func newStream(sess *session, syn *framing.SynStreamFrame) *stream {
	s := &stream{
		id:            syn.StreamId,
		priority:      syn.Priority,
		sendWindow:    sess.initialSendWindow,
		receiveWindow: sess.receiveWindow,
		reset:         make(chan struct{}),
		session:       sess,
		windowUpdate:  make(chan struct{}, 1),
		recvData:      make(chan struct{}, 1),
		ofchan: make(chan struct{}, 1),
	}
	if syn.CFHeader.Flags&framing.ControlFlagFin != 0 {
		s.receivedFin = true<commit_msg>Only create read channel if request has body.<commit_after>// Copyright (c) 2013, <NAME>
// For more information, see the LICENSE file

package spdy

import (
	"bufio"
	"bytes"
	"errors"
	"fmt"
	"github.com/DanielMorsing/spdy/framing"
	"io"
	"io/ioutil"
	"log"
	"net/http"
	"net/url"
	"sync"
)

// stream represents a spdy stream within a session
type stream struct {
	// the stream id for this stream
	id framing.StreamId

	// window size
	sendWindow    uint32
	receiveWindow uint32
	windowOffset  uint32
	priority      uint8
	reset         chan struct{}
	recvData      chan struct{}
	windowUpdate  chan struct{}
	session       *session
	receivedFin   bool
	closed        bool
	buf           bytes.Buffer
	
	// channel to communicate with outframer.
	ofchan chan struct{}

	// mutex to protect the window variables
	mu sync.Mutex
}

func newStream(sess *session, syn *framing.SynStreamFrame) *stream {
	s := &stream{
		id:            syn.StreamId,
		priority:      syn.Priority,
		sendWindow:    sess.initialSendWindow,
		receiveWindow: sess.receiveWindow,
		reset:         make(chan struct{}),
		session:       sess,
		windowUpdate:  make(chan struct{}, 1),
		ofchan: make(chan struct{}, 1),
	}
	if syn.CFHeader.Flags&framing.ControlFlagFin != 0 {
		s.receivedFin = true
	} else {
		s.recvData = make(chan struct{}, 1)
{'fraction_non_alphanumeric': 0.10265282583621683, 'fraction_numerical': 0.011534025374855825, 'mean_word_length': 2.978593272171254, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2577518', 'n_tokens_mistral': 934, 'n_tokens_neox': 859, 'n_words': 259}