// File: /workspace/github_c_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rcx, %r14
movq %rdx, %rbx
movq %rsi, %r13
movq %rdi, %r15
leaq 0xa0(%rcx), %rdi
callq 0x99e10
testb %al, %al
je 0xae4be
xorl %ebx, %ebx
jmp 0xae70d
leaq 0x20(%rsp), %rdi
xorl %r12d, %r12d
xorl %esi, %esi
callq 0x58e20
imulq %r13, %rbx
testq %rbx, %rbx
je 0xae4f5
leaq 0x20(%rsp), %r13
movsbl (%r15,%r12), %ebp
movq %r13, %rdi
movl %r12d, %esi
callq 0x58990
movl %ebp, (%rax)
incl %r12d
cmpq %r12, %rbx
ja 0xae4db
leaq 0x63eb0(%rip), %rsi     # 0x1123ac
leaq 0x38(%rsp), %rdi
callq 0x579f0
leaq 0x20(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0x577d0
movl %eax, %ebp
leaq 0x38(%rsp), %rdi
callq 0x59200
testb %bpl, %bpl
je 0xae60c
movq 0x258(%r14), %rdi
testq %rdi, %rdi
je 0xae53c
movq (%rdi), %rax
callq *0x8(%rax)
movl $0x108, %edi            # imm = 0x108
callq 0x556b0
movq %rax, %r15
leaq 0x240(%r14), %rdx
movq %rax, %rdi
movl $0x3, %esi
movl $0x1, %ecx
callq 0x582f0
movq %r15, 0x258(%r14)
addq $0x1e8, %r14            # imm = 0x1E8
movq %r14, %rdi
callq 0xaeb4c
leaq 0x38(%rsp), %rdi
callq 0x570d0
leaq 0x63e2b(%rip), %rsi     # 0x1123b4
leaq 0x38(%rsp), %rdi
callq 0x55f40
leaq 0x20(%rsp), %rdi
callq 0x57180
movl %eax, %ebp
leaq 0x7a06a(%rip), %rsi     # 0x128610
leaq 0x70(%rsp), %rdi
callq 0x579f0
leaq 0x20(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x57610
notl %eax
addl %eax, %ebp
leaq 0x8(%rsp), %rdi
leaq 0x20(%rsp), %rsi
movl %ebp, %edx
callq 0x57f90
leaq 0x50(%rsp), %r15
leaq 0x8(%rsp), %rsi
movq %r15, %rdi
callq 0x555f0
leaq 0x8(%rsp), %rdi
callq 0x59200
leaq 0x70(%rsp), %rdi
callq 0x59200
leaq 0x38(%rsp), %rsi
movq %r14, %rdi
callq 0xaee4e
jmp 0xae6f1
leaq 0x6e35a(%rip), %rsi     # 0x11c96d
leaq 0x38(%rsp), %rdi
callq 0x579f0
leaq 0x20(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0x55180
movl %eax, %ebp
leaq 0x38(%rsp), %rdi
callq 0x59200
testb %bpl, %bpl
je 0xae703
leaq 0x38(%rsp), %rdi
callq 0x570d0
leaq 0x6e31b(%rip), %rsi     # 0x11c96d
leaq 0x8(%rsp), %rdi
callq 0x579f0
leaq 0x20(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x57610
movl %eax, %ebp
leaq 0x8(%rsp), %rdi
callq 0x59200
leaq 0x8(%rsp), %rdi
leaq 0x20(%rsp), %rsi
movl %ebp, %edx
callq 0x58b00
leaq 0x38(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x555f0
leaq 0x8(%rsp), %rdi
callq 0x59200
leaq 0x20(%rsp), %rdi
callq 0x57180
subl %ebp, %eax
addl $-0x2, %eax
leaq 0x8(%rsp), %rdi
leaq 0x20(%rsp), %rsi
movl %eax, %edx
callq 0x57f90
leaq 0x50(%rsp), %r15
leaq 0x8(%rsp), %rsi
movq %r15, %rdi
callq 0x555f0
leaq 0x8(%rsp), %rdi
callq 0x59200
addq $0x1e8, %r14            # imm = 0x1E8
leaq 0x38(%rsp), %rsi
movq %r14, %rdi
callq 0xaee4e
movq %r15, %rdi
callq 0x59200
leaq 0x38(%rsp), %rdi
callq 0x59200
leaq 0x20(%rsp), %rdi
callq 0x59200
movq %rbx, %rax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xae774
jmp 0xae72a
jmp 0xae72a
jmp 0xae774
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
jmp 0xae76d
jmp 0xae774
jmp 0xae796
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x59200
jmp 0xae768
jmp 0xae774
jmp 0xae774
jmp 0xae774
jmp 0xae796
jmp 0xae785
movq %rax, %rbx
movl $0x108, %esi            # imm = 0x108
movq %r15, %rdi
callq 0x55480
jmp 0xae799
jmp 0xae796
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x59200
jmp 0xae777
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x59200
jmp 0xae788
jmp 0xae796
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x59200
jmp 0xae799
jmp 0xae796
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x59200
movq %rbx, %rdi
callq 0x57090