encode to header correctly.