/*
Copyright (c) [2023] [squallzhao]
fountain is licensed under APACHE LICENSE, VERSION 2.0.
You can use this software according to the terms and conditions of the APACHE LICENSE, VERSION 2.0.
You may obtain a copy of APACHE LICENSE, VERSION 2.0 at: https://www.apache.org/licenses/LICENSE-2.0
*/
package microservice.web.http11
import microservice.trace.*
import std.collection.*
public class Headers{
var map = HashMap<String, String>()
public func get(key: String): String{
try{
return map.get(key).getOrThrow()
} catch(e:NoneValueException){
return "";
}
}
public func put(key: String, value: String): Unit{
map.put(key,value)
}
public func toHttp(): String{
var rsp = ""
for ( (k,v) in map){
rsp += k + ":" + v +"\r\n"
}
return rsp
}
public func dump(){
for ( (k,v) in map){
Logger.trace("Header name="+k+",value="+v)
}
}
}