Skip to content

Commit

Permalink
svg support
Browse files Browse the repository at this point in the history
  • Loading branch information
nemasu committed Apr 22, 2019
1 parent 68fb3f6 commit 8070d88
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 1 deletion.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ Example: `./asmttpd ./web_root 8080`

Changes
=======
2019-01-24 : asmttpd - 0.4.4

* Added SVG support.

2019-01-24 : asmttpd - 0.4.3

* Added port number as parameter.
Expand Down
1 change: 1 addition & 0 deletions constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
%define CONTENT_TYPE_GIF 6
%define CONTENT_TYPE_PNG 7
%define CONTENT_TYPE_JPEG 8
%define CONTENT_TYPE_SVG 9

;System Call Values
%define SYS_WRITE 1 ;int fd, const void *buf, size_t count
Expand Down
4 changes: 4 additions & 0 deletions data.asm
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@
content_type_gif db "image/gif",0x0d,0x0a,0x00
content_type_gif_len equ $ - content_type_gif

content_type_svg db "image/svg+xml",0x0d,0x0a,0x00
content_type_svg_len equ $ - content_type_svg

default_document db "/index.html",0x00
default_document_len equ $ - default_document
Expand All @@ -153,3 +156,4 @@
extension_jpg db ".jpg",0x00
extension_jpeg db ".jpeg",0x00
extension_png db ".png",0x00
extension_svg db ".svg",0x00
13 changes: 13 additions & 0 deletions http.asm
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ detect_content_type: ;rdi - pointer to buffer that contains request, ret - rax:
cmp rax, 1
je detect_content_type_ret

mov rsi, extension_svg
call string_ends_with
mov r10, CONTENT_TYPE_SVG
cmp rax, 1
je detect_content_type_ret

mov r10, CONTENT_TYPE_OCTET_STREAM ; default to octet-stream
detect_content_type_ret:
mov rax, r10
Expand Down Expand Up @@ -112,6 +118,8 @@ add_content_type_header: ;rdi - pointer to buffer, rsi - type
je add_response_png
cmp r10, CONTENT_TYPE_JPEG
je add_response_jpeg
cmp r10, CONTENT_TYPE_SVG
je add_response_svg
jmp add_response_octet_stream

Expand Down Expand Up @@ -159,6 +167,11 @@ add_content_type_header: ;rdi - pointer to buffer, rsi - type
mov rsi, content_type_jpeg
call string_concat

add_response_svg:
mov rsi, content_type_svg
call string_concat


add_response_cont:
stackpop
ret
Expand Down
2 changes: 1 addition & 1 deletion main.asm
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
%include "constants.asm"
%include "macros.asm"

%define ASMTTPD_VERSION "0.4.3"
%define ASMTTPD_VERSION "0.4.4"

%define THREAD_COUNT 10 ; Number of worker threads

Expand Down

0 comments on commit 8070d88

Please sign in to comment.