// ParseHeader attempts to parse a header out of the given string.
ParseHeader attempts to parse a header out of the given string.
// ParseHeader attempts to parse a header out of the given string .
func ParseHeader(line string) (*Message, error) {
	line = strings.TrimSpace(line)
	if line == "" {
		return nil, errors.New("not a header spec: Empty line")
	}
	parts := strings.SplitN(line, " ", 2)
	if len(parts) != 2 {
		return nil, fmt.Errorf("not a header spec: \"%s\"", line)
	}
	codeStr := strings.TrimSpace(parts[0])
	code, err := strconv.ParseUint(codeStr, 10, 64)
	if err != nil {
		return nil, fmt.Errorf("could not parse Status Code: %v", err)
	}
	desc := strings.TrimSpace(parts[1])
	if desc == "" {
		return nil, fmt.Errorf("empty description header for \"%s\"", line)
	}
	msg := &Message{
		StatusCode:  code,
		Description: desc,
		Fields:      make(map[string]string),
	}
	return msg, nil
}
func ParseHeader ( line string ) ( * Message , error ) { line = strings . TrimSpace ( line ) if line == " " { return nil , errors . New ( " " ) } parts := strings . SplitN ( line , " " , 2 ) if len ( parts ) != 2 { return nil , fmt . Errorf ( " \" \" " , line ) } codeStr := strings . TrimSpace ( parts [ 0 ] ) code , err := strconv . ParseUint ( codeStr , 10 , 64 ) if err != nil { return nil , fmt . Errorf ( " " , err ) } desc := strings . TrimSpace ( parts [ 1 ] ) if desc == " " { return nil , fmt . Errorf ( " \" \" " , line ) } msg := & Message { StatusCode : code , Description : desc , Fields : make ( map [ string ] string ) , } return msg , nil }
ParseHeader attempts to parse a header out of the given string.
ParseHeader attempts to parse a header out of the given string .