add support for http client uploads

fixes #27
This commit is contained in:
Lucas Clemente
2016-05-13 13:01:45 +02:00
parent c0c7650431
commit d1272650c3
6 changed files with 59 additions and 48 deletions

View File

@@ -526,12 +526,24 @@ func (s *Session) QueueStreamFrame(frame *frames.StreamFrame) error {
func (s *Session) NewStream(id protocol.StreamID) (utils.Stream, error) {
s.streamsMutex.Lock()
defer s.streamsMutex.Unlock()
stream, err := newStream(s, s.connectionParametersManager, id)
return s.newStreamImpl(id)
}
// GetOrCreateStream returns an existing stream with the given id, or opens a new stream
func (s *Session) GetOrCreateStream(id protocol.StreamID) (utils.Stream, error) {
s.streamsMutex.Lock()
defer s.streamsMutex.Unlock()
if stream, ok := s.streams[id]; ok {
return stream, nil
}
return s.newStreamImpl(id)
}
func (s *Session) newStreamImpl(id protocol.StreamID) (*stream, error) {
stream, err := newStream(s, s.connectionParametersManager, id)
if err != nil {
return nil, err
}
if s.streams[id] != nil {
return nil, fmt.Errorf("Session: stream with ID %d already exists", id)
}