Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Byte wise comparison #60

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions data.asm
Original file line number Diff line number Diff line change
Expand Up @@ -171,3 +171,8 @@
http_dir_entry_open_a_tag_pre db '<p><a href="',0x00
http_dir_entry_open_a_tag_post db '">',0x00
http_dir_entry_close_a_tag db '</a></p>',0x00

; Request type
request_types db "GET ", "HEAD " ; space after each request type
request_values db REQ_GET, REQ_HEAD
num_requests equ ($ - request_types) / 4
36 changes: 15 additions & 21 deletions http.asm
Original file line number Diff line number Diff line change
Expand Up @@ -410,28 +410,22 @@ get_request_type: ;rdi - pointer to buffer, ret = rax: request type
mov rax, r10
add rax, 0x03
mov [request_offset], rax

mov rax, REQ_UNK

check_get:
cmp byte[rdi+0], 0x47
jne check_head
cmp byte[rdi+1], 0x45
jne check_head
cmp byte[rdi+2], 0x54
jne check_head
mov rax, REQ_GET

check_head:
cmp byte[rdi+0], 0x48
jne request_type_return
cmp byte[rdi+1], 0x45
jne request_type_return
cmp byte[rdi+2], 0x41
jne request_type_return
cmp byte[rdi+3], 0x44
jne request_type_return
mov rax, REQ_HEAD

check_request_loop:
mov edx, [rdi]
lea rsi, [request_types + rbx * 4]
cmp edx, [rsi]
jne next_request

movzx rax, byte [request_values + rbx]
jmp request_type_return

next_request:
inc rbx
cmp rbx, num_requests
jl check_request_loop

request_type_return:
stackpop
Expand Down