// File: /workspace/github_c_makefile_star2_O0/enzo1982[P]smooth/classes/net/protocols/http.cpp
// Function: smooth::Net::Protocols::httpHeader(char*, unsigned long, unsigned long, void*)
size_t S::Net::Protocols::httpHeader(char *buffer, size_t size, size_t n, void *data)
{
	HTTP	*http = (HTTP *) data;

	/* Cancel request if requested.
	 */
	if (http->doCancelDownload.Call()) return 0;

	/* Get data as string.
	 */
	String	 header;

	for (UnsignedInt i = 0; i < size * n; i++) header[i] = buffer[i];

	/* Handle headers.
	 */
	if (header.StartsWith("HTTP/1."))
	{
		/* Reset output stream when we get a new HTTP response.
		 */
		delete http->out;

		http->out = new IO::OutStream(IO::STREAM_FILE, http->file, IO::OS_REPLACE);

		http->responseFields.RemoveAll();

		/* Add status code to header fields.
		 */
		Parameter	 field;

		field.key	= "Status-Code";
		field.value	= header.Tail(header.Length() - header.Find(" ") - 1);

		http->responseFields.Add(field);
	}
	else if (header.Contains(": "))
	{
		/* Split header into key and value.
		 */
		Parameter	 field;
		Int		 colon	= header.Find(": ");

		field.key	= header.Head(colon);
		field.value	= header.Tail(header.Length() - colon - 2);

		http->responseFields.Add(field);
	}

	return size * n;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1c0, %rsp            # imm = 0x1C0
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
addq $0xa0, %rdi
callq 0x1049c0
testb $0x1, %al
jne 0x103f19
jmp 0x103f26
movq $0x0, -0x8(%rbp)
jmp 0x1043bb
leaq -0x48(%rbp), %rdi
xorl %esi, %esi
callq 0x5da90
movl $0x0, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
movq -0x18(%rbp), %rcx
imulq -0x20(%rbp), %rcx
cmpq %rcx, %rax
jae 0x103f99
movq -0x10(%rbp), %rax
movl -0x4c(%rbp), %ecx
movl %ecx, %esi
movsbl (%rax,%rcx), %eax
movl %eax, -0x18c(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x5d4e0
movq %rax, -0x188(%rbp)
jmp 0x103f6e
movq -0x188(%rbp), %rax
movl -0x18c(%rbp), %ecx
movl %ecx, (%rax)
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x103f38
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x1043b0
leaq 0xa1d1c(%rip), %rsi     # 0x1a5cbc
leaq -0x78(%rbp), %rdi
callq 0x5c1f0
jmp 0x103fab
leaq -0x48(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x5bf60
movb %al, -0x18d(%rbp)
jmp 0x103fc0
leaq -0x78(%rbp), %rdi
callq 0x5df00
movb -0x18d(%rbp), %al
testb $0x1, %al
jne 0x103fd8
jmp 0x1041be
movq -0x30(%rbp), %rax
movq 0x258(%rax), %rax
movq %rax, -0x198(%rbp)
cmpq $0x0, %rax
je 0x103ffd
movq -0x198(%rbp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
movl $0x108, %edi            # imm = 0x108
callq 0x59820
movq %rax, -0x1a0(%rbp)
jmp 0x104010
movq -0x1a0(%rbp), %rdi
movq -0x30(%rbp), %rdx
addq $0x240, %rdx            # imm = 0x240
movl $0x3, %esi
movl $0x1, %ecx
callq 0x5ccd0
jmp 0x104033
movq -0x1a0(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x258(%rax)
movq -0x30(%rbp), %rdi
addq $0x1e8, %rdi            # imm = 0x1E8
callq 0x1049e0
jmp 0x104057
leaq -0xb0(%rbp), %rdi
callq 0x5b6f0
jmp 0x104065
leaq 0xa1c58(%rip), %rsi     # 0x1a5cc4
leaq -0xb0(%rbp), %rdi
callq 0x5a230
jmp 0x10407a
leaq -0x48(%rbp), %rdi
callq 0x5b800
movl %eax, -0x1a4(%rbp)
jmp 0x10408b
leaq 0xb7eee(%rip), %rsi     # 0x1bbf80
leaq -0xe0(%rbp), %rdi
callq 0x5c1f0
jmp 0x1040a0
leaq -0x48(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x5bd60
movl %eax, -0x1a8(%rbp)
jmp 0x1040b8
movl -0x1a4(%rbp), %eax
movl -0x1a8(%rbp), %edx
notl %edx
addl %eax, %edx
leaq -0xc8(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x5c8a0
jmp 0x1040da
leaq -0x98(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x59760
jmp 0x1040ef
leaq -0xc8(%rbp), %rdi
callq 0x5df00
leaq -0xe0(%rbp), %rdi
callq 0x5df00
movq -0x30(%rbp), %rdi
addq $0x1e8, %rdi            # imm = 0x1E8
leaq -0xb0(%rbp), %rsi
callq 0x1048d0
jmp 0x104120
leaq -0xb0(%rbp), %rdi
callq 0x5de58
jmp 0x104398
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x5df00
jmp 0x1043b0
movq -0x1a0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
movl $0x108, %esi            # imm = 0x108
callq 0x595b0
jmp 0x1043b0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x1041ad
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x1041a1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0x5df00
leaq -0xe0(%rbp), %rdi
callq 0x5df00
leaq -0xb0(%rbp), %rdi
callq 0x5de58
jmp 0x1043b0
leaq 0xac0f8(%rip), %rsi     # 0x1b02bd
leaq -0xf8(%rbp), %rdi
callq 0x5c1f0
jmp 0x1041d3
leaq -0x48(%rbp), %rdi
leaq -0xf8(%rbp), %rsi
callq 0x591d0
movb %al, -0x1a9(%rbp)
jmp 0x1041eb
leaq -0xf8(%rbp), %rdi
callq 0x5df00
movb -0x1a9(%rbp), %al
testb $0x1, %al
jne 0x104206
jmp 0x104396
leaq -0x130(%rbp), %rdi
callq 0x5b6f0
jmp 0x104214
leaq 0xac0a2(%rip), %rsi     # 0x1b02bd
leaq -0x150(%rbp), %rdi
callq 0x5c1f0
jmp 0x104229
leaq -0x48(%rbp), %rdi
leaq -0x150(%rbp), %rsi
callq 0x5bd60
movl %eax, -0x1b0(%rbp)
jmp 0x104241
leaq -0x150(%rbp), %rdi
callq 0x5df00
movl -0x1b0(%rbp), %eax
movl %eax, -0x134(%rbp)
movl -0x134(%rbp), %edx
leaq -0x168(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x5d6b0
jmp 0x104271
leaq -0x130(%rbp), %rdi
leaq -0x168(%rbp), %rsi
callq 0x59760
jmp 0x104286
leaq -0x168(%rbp), %rdi
callq 0x5df00
leaq -0x48(%rbp), %rdi
callq 0x5b800
movl %eax, -0x1b4(%rbp)
jmp 0x1042a3
movl -0x1b4(%rbp), %edx
movl -0x134(%rbp), %eax
subl %eax, %edx
addl $-0x2, %edx
leaq -0x180(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x5c8a0
jmp 0x1042c6
leaq -0x118(%rbp), %rdi
leaq -0x180(%rbp), %rsi
callq 0x59760
jmp 0x1042db
leaq -0x180(%rbp), %rdi
callq 0x5df00
movq -0x30(%rbp), %rdi
addq $0x1e8, %rdi            # imm = 0x1E8
leaq -0x130(%rbp), %rsi
callq 0x1048d0
jmp 0x104300
leaq -0x130(%rbp), %rdi
callq 0x5de58
jmp 0x104396
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0xf8(%rbp), %rdi
callq 0x5df00
jmp 0x1043b0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x104388
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x150(%rbp), %rdi
callq 0x5df00
jmp 0x104388
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x168(%rbp), %rdi
callq 0x5df00
jmp 0x104388
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x180(%rbp), %rdi
callq 0x5df00
leaq -0x130(%rbp), %rdi
callq 0x5de58
jmp 0x1043b0
jmp 0x104398
movq -0x18(%rbp), %rax
imulq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x5df00
jmp 0x1043bb
leaq -0x48(%rbp), %rdi
callq 0x5df00
jmp 0x1043c8
movq -0x8(%rbp), %rax
addq $0x1c0, %rsp            # imm = 0x1C0
popq %rbp
retq
movq -0x58(%rbp), %rdi
callq 0x5b6b0
nopw %cs:(%rax,%rax)