func (this *ViaParser) Parse() (sh header.Header, ParseException error) { lexer := this.GetLexer() viaList := header.NewViaList() // The first via header. lexer.Match(TokenTypes_VIA) lexer.SPorHT() // ignore blanks lexer.Match(':') // expect a colon. lexer.SPorHT() // ingore blanks. for { v := header.NewVia() if ParseException = this.ParseVia(v); ParseException != nil { return nil, ParseException } viaList.PushBack(v) lexer.SPorHT() // eat whitespace. if la, _ := lexer.LookAheadK(0); la == ',' { lexer.ConsumeK(1) // Consume the comma lexer.SPorHT() // Ignore space after. } if la, _ := lexer.LookAheadK(0); la == '\n' { break } } lexer.Match('\n') return viaList, nil }
/** Set A list of via headers. *@param - a list of via headers to add. */ func (this *SIPMessage) SetVia(viaList *header.ViaList) { vList := header.NewViaList() for it := viaList.Front(); it != nil; it = it.Next() { via := it.Value.(*header.Via) vList.PushBack(via) } this.SetHeader(vList) }