

function(ParseHttpResponse result http_response)
	string(FIND  "${http_response}" "200 OK" beginOfReponse)
	if(beginOfReponse LESS 0)
		element()
		value(KEY code VALUE 404)
		string(REPLACE "\r\n" "\n" "${http_response}"  http_response)
		value(KEY raw "${http_response}")
		element(END res)
		
		return_value(${res})
	endif()
	math(EXPR beginOfReponse "${beginOfReponse} + 6")
	string(SUBSTRING "${http_response}" ${beginOfReponse} -1 response)
	string(FIND "${response}" "Content-Length:" beginOfContent)
	string(SUBSTRING "${response}" 0 ${beginOfContent} header)
	string(SUBSTRING "${response}" ${beginOfContent} -1 content)

	string(REGEX REPLACE "\;" "," header "${response}")
	string_split( "${response}" "\n")
	ans(lines)
	set(contentStarted false)
	set(content)


	element()
	value(KEY code VALUE 200)
	element(headers )
	foreach(line ${lines})
		if(contentStarted)
			set(content "${content}\n${line}")
			else()
		string(STRIP "${line}" line)
		string(REGEX REPLACE "([^:]*):(.*)" "\\1" header_name "${line}")
		string(REGEX REPLACE "([^:]*):(.*)" "\\2" header_value "${line}")
		string(STRIP "${header_value}" header_value)
		value(KEY "${header_name}" "${header_value}")
		if("${header_name}" STREQUAL "Content-Length")
		set(contentStarted true)
			set(contentLength ${header_value})
		endif()

		endif()
	endforeach()
	element(END)
	#message("${http_response}")
	string(STRIP "${content}" content)
	string(SUBSTRING "${content}" 0 ${header_value} content)
	value(KEY Content "${content}")
	element(END response)	
	map_navigate(contentType "response.headers.Content-Type")

	if("${contentType}" STREQUAL "application/json")	
		json_deserialize( "${content}")
		ans(content)
		map_set(${response} "Content" "${content}")
	endif()
	return_value(${response})
endfunction()