; generated by Component: ARM Compiler 5.05 update 2 (build 169) Tool: ArmCC [4d0f38]
; commandline ArmCC [--c99 --list --split_sections --debug -c --asm --interleave -o..\..\..\..\build\demo\mico-fire_f429\obj_rvmdk\httpd_wsgi.o --asm_dir=..\..\..\..\Build\demo\MICO-Fire_F429\list_RVMDK\ --list_dir=..\..\..\..\Build\demo\MICO-Fire_F429\list_RVMDK\ --depend=..\..\..\..\build\demo\mico-fire_f429\obj_rvmdk\httpd_wsgi.d --cpu=Cortex-M4.fp --apcs=interwork -O0 --diag_suppress=9931,1,1293 -I..\..\..\..\Board\fire_F429 -I..\..\..\..\Demos\fire\ov2640 -I..\..\..\..\include -I..\..\..\..\libraries\utilities -I..\..\..\..\libraries\utilities\json_c -I..\..\..\..\MICO\core -I..\..\..\..\MICO\security -I..\..\..\..\MICO\system -I..\..\..\..\MICO\system\command_console -I..\..\..\..\Platform\include -I..\..\..\..\Platform\Cortex-M4 -I..\..\..\..\Platform\Cortex-M4\CMSIS -I..\..\..\..\Platform\MCU\STM32F4xx\peripherals -I..\..\..\..\Platform\MCU\STM32F4xx\peripherals\Libraries\STM32F4xx_StdPeriph_Driver\inc -I..\..\..\..\Platform\MCU\STM32F4xx\peripherals\Libraries -I..\..\..\..\Platform\MCU\STM32F4xx\wlan_bus_driver -I..\..\..\..\Platform\Drivers\spi_flash -I..\..\..\..\Platform\Drivers -I..\..\..\..\libraries\daemons\homekit_server -I..\..\..\..\libraries\daemons\http_server -I..\..\..\..\Platform\Drivers\malloc -I..\..\..\..\Platform\Drivers\SDRAM -I..\..\..\..\Platform\Drivers\ov5640 -IG:\GIT_OSC\STM32_develop\F429-V2\develop\6-WIFI\STM32-WiFi\3.wifi_ov5640\Projects\STM32F429\demo\RVMDK\RTE -IC:\Keil_v5\ARM\PACK\Keil\STM32F4xx_DFP\2.5.0\Drivers\CMSIS\Device\ST\STM32F4xx\Include -IC:\Keil_v5\ARM\CMSIS\Include -IC:\Keil_v5\ARM\PACK\Keil\STM32F4xx_DFP\2.5.0 -D__UVISION_VERSION=515 -DSTM32F429xx -DUSE_STDPERIPH_DRIVER -DDEBUG -DHSE_VALUE=25000000 -DOV5640 --omf_browse=..\..\..\..\build\demo\mico-fire_f429\obj_rvmdk\httpd_wsgi.crf ..\..\..\..\libraries\daemons\http_server\httpd_wsgi.c]
                          THUMB

                          AREA ||i.chunked_encoding||, CODE, READONLY, ALIGN=1

                  chunked_encoding PROC
;;;274    
;;;275    static inline bool chunked_encoding(httpd_request_t *req)
000000  4601              MOV      r1,r0
;;;276    {
;;;277    	return req->wsgi->hdr_fields & HTTPD_HDR_ADD_TYPE_CHUNKED;
000002  6d88              LDR      r0,[r1,#0x58]
000004  7900              LDRB     r0,[r0,#4]
000006  f3c000c0          UBFX     r0,r0,#3,#1
;;;278    }
00000a  4770              BX       lr
;;;279    
                          ENDP


                          AREA ||i.get_matching_chars||, CODE, READONLY, ALIGN=1

                  get_matching_chars PROC
;;;545    
;;;546    static int get_matching_chars(const char *s1, const char *s2)
000000  b530              PUSH     {r4,r5,lr}
;;;547    {
000002  4602              MOV      r2,r0
;;;548    	int match = 0;
000004  2000              MOVS     r0,#0
;;;549    
;;;550    	if (s1 != NULL && s2 != NULL) {
000006  b142              CBZ      r2,|L2.26|
000008  b139              CBZ      r1,|L2.26|
;;;551    		while (*s1++ == *s2++)
00000a  e000              B        |L2.14|
                  |L2.12|
;;;552    			match++;
00000c  1c40              ADDS     r0,r0,#1
                  |L2.14|
00000e  f8124b01          LDRB     r4,[r2],#1            ;551
000012  f8115b01          LDRB     r5,[r1],#1            ;551
000016  42ac              CMP      r4,r5                 ;551
000018  d0f8              BEQ      |L2.12|
                  |L2.26|
;;;553    	}
;;;554    	return match;
;;;555    
;;;556    }
00001a  bd30              POP      {r4,r5,pc}
;;;557    
                          ENDP


                          AREA ||i.httpd_get_data||, CODE, READONLY, ALIGN=1

                  httpd_get_data PROC
;;;499    }
;;;500    int httpd_get_data(httpd_request_t *req, char *content, int length)
000000  e92d41f0          PUSH     {r4-r8,lr}
;;;501    {
000004  4604              MOV      r4,r0
000006  460f              MOV      r7,r1
000008  4690              MOV      r8,r2
;;;502    	int ret;
;;;503    	char *buf;
;;;504    
;;;505    	/* Is this condition required? */
;;;506    	if (req->body_nbytes >= HTTPD_MAX_MESSAGE - 2)
00000a  6d60              LDR      r0,[r4,#0x54]
00000c  f5b07fff          CMP      r0,#0x1fe
000010  db03              BLT      |L3.26|
;;;507    		return -kInProgressErr;
000012  f04f30ff          MOV      r0,#0xffffffff
                  |L3.22|
;;;508    
;;;509    
;;;510    	buf = malloc(HTTPD_MAX_MESSAGE);
;;;511    	if (!buf) {
;;;512    		httpd_d("Failed to allocate memory for buffer");
;;;513    		return -kInProgressErr;
;;;514    	}
;;;515    
;;;516    	if (!req->hdr_parsed) {
;;;517    		ret = httpd_parse_hdr_tags(req, req->sock, buf,
;;;518    			HTTPD_MAX_MESSAGE);
;;;519    
;;;520    		if (ret != kNoErr) {
;;;521    			httpd_d("Unable to parse header tags");
;;;522    			goto out;
;;;523    		} else {
;;;524    			httpd_d("Headers parsed successfully\r\n");
;;;525    			req->hdr_parsed = 1;
;;;526    		}
;;;527    	}
;;;528    
;;;529    	/* handle here */
;;;530    	ret = httpd_recv(req->sock, content,
;;;531    			length, 0);
;;;532    	if (ret == -1) {
;;;533    		httpd_d("Failed to read POST data");
;;;534    		goto out;
;;;535    	}
;;;536    	/* scratch will now have the JSON data */
;;;537    	content[ret] = '\0';
;;;538    	req->remaining_bytes -= ret;
;;;539    	httpd_d("Read %d bytes and remaining %d bytes",
;;;540    		ret, req->remaining_bytes);
;;;541    out:
;;;542    	free(buf);
;;;543    	return req->remaining_bytes;
;;;544    }
000016  e8bd81f0          POP      {r4-r8,pc}
                  |L3.26|
00001a  f44f7000          MOV      r0,#0x200             ;510
00001e  f7fffffe          BL       malloc
000022  4606              MOV      r6,r0                 ;510
000024  b916              CBNZ     r6,|L3.44|
000026  f04f30ff          MOV      r0,#0xffffffff        ;513
00002a  e7f4              B        |L3.22|
                  |L3.44|
00002c  f894004c          LDRB     r0,[r4,#0x4c]         ;516
000030  b960              CBNZ     r0,|L3.76|
000032  f44f7300          MOV      r3,#0x200             ;517
000036  4632              MOV      r2,r6                 ;517
000038  4620              MOV      r0,r4                 ;517
00003a  6ca1              LDR      r1,[r4,#0x48]         ;517
00003c  f7fffffe          BL       httpd_parse_hdr_tags
000040  4605              MOV      r5,r0                 ;517
000042  b105              CBZ      r5,|L3.70|
000044  e012              B        |L3.108|
                  |L3.70|
000046  2001              MOVS     r0,#1                 ;525
000048  f884004c          STRB     r0,[r4,#0x4c]         ;525
                  |L3.76|
00004c  2300              MOVS     r3,#0                 ;530
00004e  4642              MOV      r2,r8                 ;530
000050  4639              MOV      r1,r7                 ;530
000052  6ca0              LDR      r0,[r4,#0x48]         ;530
000054  f7fffffe          BL       httpd_recv
000058  4605              MOV      r5,r0                 ;530
00005a  1c68              ADDS     r0,r5,#1              ;532
00005c  b900              CBNZ     r0,|L3.96|
00005e  e005              B        |L3.108|
                  |L3.96|
000060  2000              MOVS     r0,#0                 ;537
000062  5578              STRB     r0,[r7,r5]            ;537
000064  6d20              LDR      r0,[r4,#0x50]         ;538
000066  1b40              SUBS     r0,r0,r5              ;538
000068  6520              STR      r0,[r4,#0x50]         ;538
00006a  bf00              NOP                            ;541
                  |L3.108|
00006c  4630              MOV      r0,r6                 ;542
00006e  f7fffffe          BL       free
000072  6d20              LDR      r0,[r4,#0x50]         ;543
000074  e7cf              B        |L3.22|
;;;545    
                          ENDP


                          AREA ||i.httpd_purge_headers||, CODE, READONLY, ALIGN=1

                  httpd_purge_headers PROC
;;;149    
;;;150    int httpd_purge_headers(int sock)
000000  b538              PUSH     {r3-r5,lr}
;;;151    {
000002  4605              MOV      r5,r0
;;;152    	unsigned char ch;
;;;153    	httpd_purge_state_t purge_state = ANY_OTHER_CHAR;
000004  2400              MOVS     r4,#0
;;;154    	while (httpd_recv(sock, &ch, 1, 0) != 0) {
000006  e019              B        |L4.60|
                  |L4.8|
;;;155    		switch (ch) {
000008  f89d0000          LDRB     r0,[sp,#0]
00000c  280a              CMP      r0,#0xa
00000e  d007              BEQ      |L4.32|
000010  280d              CMP      r0,#0xd
000012  d10c              BNE      |L4.46|
;;;156    		case '\r':
;;;157    			if (purge_state == ANY_OTHER_CHAR)
000014  b904              CBNZ     r4,|L4.24|
;;;158    				purge_state = FIRST_CR_FOUND;
000016  2401              MOVS     r4,#1
                  |L4.24|
;;;159    			if (purge_state == FIRST_LF_FOUND)
000018  2c02              CMP      r4,#2
00001a  d100              BNE      |L4.30|
;;;160    				purge_state = SECOND_CR_FOUND;
00001c  2403              MOVS     r4,#3
                  |L4.30|
;;;161    			break;
00001e  e008              B        |L4.50|
                  |L4.32|
;;;162    		case '\n':
;;;163    			if (purge_state == FIRST_CR_FOUND)
000020  2c01              CMP      r4,#1
000022  d100              BNE      |L4.38|
;;;164    				purge_state = FIRST_LF_FOUND;
000024  2402              MOVS     r4,#2
                  |L4.38|
;;;165    			if (purge_state == SECOND_CR_FOUND)
000026  2c03              CMP      r4,#3
000028  d100              BNE      |L4.44|
;;;166    				purge_state = SECOND_LF_FOUND;
00002a  2404              MOVS     r4,#4
                  |L4.44|
;;;167    			break;
00002c  e001              B        |L4.50|
                  |L4.46|
;;;168    		default:
;;;169    			purge_state = ANY_OTHER_CHAR;
00002e  2400              MOVS     r4,#0
000030  bf00              NOP                            ;155
                  |L4.50|
000032  bf00              NOP                            ;161
;;;170    
;;;171    		}
;;;172    		if (purge_state == SECOND_LF_FOUND)
000034  2c04              CMP      r4,#4
000036  d101              BNE      |L4.60|
;;;173    			return kNoErr;
000038  2000              MOVS     r0,#0
                  |L4.58|
;;;174    	}
;;;175    	return -kInProgressErr;
;;;176    }
00003a  bd38              POP      {r3-r5,pc}
                  |L4.60|
00003c  2300              MOVS     r3,#0                 ;154
00003e  2201              MOVS     r2,#1                 ;154
000040  4669              MOV      r1,sp                 ;154
000042  4628              MOV      r0,r5                 ;154
000044  f7fffffe          BL       httpd_recv
000048  2800              CMP      r0,#0                 ;154
00004a  d1dd              BNE      |L4.8|
00004c  1e40              SUBS     r0,r0,#1              ;175
00004e  e7f4              B        |L4.58|
;;;177    
                          ENDP


                          AREA ||i.httpd_register_wsgi_handler||, CODE, READONLY, ALIGN=2

                  httpd_register_wsgi_handler PROC
;;;51     /* Register a WSGI call in the list of handlers */
;;;52     int httpd_register_wsgi_handler(struct httpd_wsgi_call *wsgi_call)
000000  b570              PUSH     {r4-r6,lr}
;;;53     {
000002  4605              MOV      r5,r0
;;;54     	int i, store_index = -1;
000004  f04f36ff          MOV      r6,#0xffffffff
;;;55     
;;;56     	if (!wsgi_call->uri)
000008  6828              LDR      r0,[r5,#0]
00000a  b908              CBNZ     r0,|L5.16|
;;;57     		return kNoErr;
00000c  2000              MOVS     r0,#0
                  |L5.14|
;;;58     
;;;59     	for (i = 0; i < MAX_WSGI_HANDLERS; i++) {
;;;60     		/*Find the first empty location in the calls array */
;;;61     		if (!calls[i] && store_index == -1) {
;;;62     			httpd_d("Found empty location %d", i);
;;;63     			store_index = i;
;;;64     			continue;
;;;65     		}
;;;66     		if (strcmp(calls[i]->uri, wsgi_call->uri) == 0) {
;;;67     			httpd_d("Found wsgi %s at slot %d",
;;;68     			      wsgi_call->uri, i);
;;;69     			return kNoErr;
;;;70     		}
;;;71     	}
;;;72     	if (store_index == -1) {
;;;73     		httpd_d("Array full.. Cannot register wsgi %s", wsgi_call->uri);
;;;74     		return -kInProgressErr;
;;;75     	}
;;;76     
;;;77     	httpd_d("Register wsgi %s at %d", wsgi_call->uri,
;;;78     	      store_index);
;;;79     
;;;80     	calls[store_index] = wsgi_call;
;;;81     	return kNoErr;
;;;82     }
00000e  bd70              POP      {r4-r6,pc}
                  |L5.16|
000010  2400              MOVS     r4,#0                 ;59
000012  e013              B        |L5.60|
                  |L5.20|
000014  480f              LDR      r0,|L5.84|
000016  f8500024          LDR      r0,[r0,r4,LSL #2]     ;61
00001a  b918              CBNZ     r0,|L5.36|
00001c  1c70              ADDS     r0,r6,#1              ;61
00001e  b908              CBNZ     r0,|L5.36|
000020  4626              MOV      r6,r4                 ;63
000022  e00a              B        |L5.58|
                  |L5.36|
000024  4a0b              LDR      r2,|L5.84|
000026  f8522024          LDR      r2,[r2,r4,LSL #2]     ;66
00002a  6829              LDR      r1,[r5,#0]            ;66
00002c  6810              LDR      r0,[r2,#0]            ;66
00002e  f7fffffe          BL       strcmp
000032  b908              CBNZ     r0,|L5.56|
000034  2000              MOVS     r0,#0                 ;69
000036  e7ea              B        |L5.14|
                  |L5.56|
000038  bf00              NOP                            ;64
                  |L5.58|
00003a  1c64              ADDS     r4,r4,#1              ;59
                  |L5.60|
00003c  2c20              CMP      r4,#0x20              ;59
00003e  dbe9              BLT      |L5.20|
000040  1c70              ADDS     r0,r6,#1              ;72
000042  b910              CBNZ     r0,|L5.74|
000044  f04f30ff          MOV      r0,#0xffffffff        ;74
000048  e7e1              B        |L5.14|
                  |L5.74|
00004a  4802              LDR      r0,|L5.84|
00004c  f8405026          STR      r5,[r0,r6,LSL #2]     ;80
000050  2000              MOVS     r0,#0                 ;81
000052  e7dc              B        |L5.14|
;;;83     
                          ENDP

                  |L5.84|
                          DCD      calls

                          AREA ||i.httpd_register_wsgi_handlers||, CODE, READONLY, ALIGN=1

                  httpd_register_wsgi_handlers PROC
;;;84     
;;;85     int httpd_register_wsgi_handlers(struct httpd_wsgi_call *wsgi_call_list, int
000000  e92d41f0          PUSH     {r4-r8,lr}
;;;86     					handlers_no)
;;;87     {
000004  4606              MOV      r6,r0
000006  460f              MOV      r7,r1
;;;88     	int i, ret, err = 0;
000008  f04f0800          MOV      r8,#0
;;;89     
;;;90     	for (i = 0; i < handlers_no; i++) {
00000c  2400              MOVS     r4,#0
00000e  e00a              B        |L6.38|
                  |L6.16|
;;;91     		ret = httpd_register_wsgi_handler(&wsgi_call_list[i]);
000010  ebc401c4          RSB      r1,r4,r4,LSL #3
000014  eb060081          ADD      r0,r6,r1,LSL #2
000018  f7fffffe          BL       httpd_register_wsgi_handler
00001c  4605              MOV      r5,r0
;;;92     		if (ret != kNoErr) {
00001e  b10d              CBZ      r5,|L6.36|
;;;93     			httpd_d("Error in registering %s handler\r\n",
;;;94     				wsgi_call_list[i].uri);
;;;95     			err++;
000020  f1080801          ADD      r8,r8,#1
                  |L6.36|
000024  1c64              ADDS     r4,r4,#1              ;90
                  |L6.38|
000026  42bc              CMP      r4,r7                 ;90
000028  dbf2              BLT      |L6.16|
;;;96     		}
;;;97     	}
;;;98     	if (err)
00002a  f1b80f00          CMP      r8,#0
00002e  d003              BEQ      |L6.56|
;;;99     		return -kInProgressErr;
000030  f04f30ff          MOV      r0,#0xffffffff
                  |L6.52|
;;;100    	else
;;;101    		return kNoErr;
;;;102    }
000034  e8bd81f0          POP      {r4-r8,pc}
                  |L6.56|
000038  2000              MOVS     r0,#0                 ;101
00003a  e7fb              B        |L6.52|
;;;103    
                          ENDP


                          AREA ||i.httpd_send_all_header||, CODE, READONLY, ALIGN=2

                          REQUIRE _printf_percent
                          REQUIRE _printf_d
                          REQUIRE _printf_int_dec
                  httpd_send_all_header PROC
;;;365    
;;;366    int httpd_send_all_header(httpd_request_t *req, const char *first_line, int body_lenth, const char *content_type)
000000  e92d47fc          PUSH     {r2-r10,lr}
;;;367    {
000004  4604              MOV      r4,r0
000006  460e              MOV      r6,r1
000008  4617              MOV      r7,r2
00000a  4698              MOV      r8,r3
;;;368      int ret;
;;;369    
;;;370      /* Parse the header tags. This is valid only for GET or HEAD request */
;;;371      if (req->type == HTTPD_REQ_TYPE_GET ||
00000c  6820              LDR      r0,[r4,#0]
00000e  2802              CMP      r0,#2
000010  d002              BEQ      |L7.24|
;;;372        req->type == HTTPD_REQ_TYPE_HEAD) {
000012  6820              LDR      r0,[r4,#0]
000014  2810              CMP      r0,#0x10
000016  d107              BNE      |L7.40|
                  |L7.24|
;;;373        ret = httpd_purge_headers(req->sock);
000018  6ca0              LDR      r0,[r4,#0x48]
00001a  f7fffffe          BL       httpd_purge_headers
00001e  4605              MOV      r5,r0
;;;374    
;;;375        if (ret != kNoErr) {
000020  b115              CBZ      r5,|L7.40|
;;;376            httpd_d("Unable to purge headers");
;;;377            return ret;
000022  4628              MOV      r0,r5
                  |L7.36|
;;;378        }
;;;379      }
;;;380    
;;;381      ret = httpd_send(req->sock, first_line, strlen(first_line));
;;;382      if (ret != kNoErr) {
;;;383          httpd_d("Error in sending the first line");
;;;384          return ret;
;;;385      }
;;;386    
;;;387      /* Send default headers */
;;;388      httpd_d("HTTP Req for URI %s", req->wsgi->uri);
;;;389      if (req->wsgi->hdr_fields) {
;;;390        ret = httpd_send_default_headers(req->sock, req->wsgi->hdr_fields);
;;;391        if (ret != kNoErr) {
;;;392          httpd_d("Error in sending default headers");
;;;393          return ret;
;;;394        }
;;;395      }
;;;396      /*send Connection heafer*/
;;;397      ret = httpd_send(req->sock, http_header_keep_alive_ctrl, strlen(http_header_keep_alive_ctrl));
;;;398      if (ret != kNoErr) {
;;;399        httpd_d("Error in sending Connection");
;;;400        return ret;
;;;401      }
;;;402      
;;;403      ret = httpd_send_header(req->sock, "Content-Type", content_type);
;;;404      if (ret != kNoErr) {
;;;405        httpd_d("Error in sending Content-Type");
;;;406        return ret;
;;;407      }
;;;408    
;;;409      /* Send Content-Length*/
;;;410      /* 6 should be more than enough */
;;;411      char con_len[6];
;;;412      snprintf(con_len, sizeof(con_len), "%d", body_lenth);
;;;413    
;;;414      ret = httpd_send_header(req->sock, "Content-Length", con_len);
;;;415      if (ret != kNoErr) {
;;;416        httpd_d("Error in sending Content-Length");
;;;417        return ret;
;;;418      }
;;;419    
;;;420      httpd_send_crlf(req->sock);
;;;421    
;;;422      return ret;
;;;423    }
000024  e8bd87fc          POP      {r2-r10,pc}
                  |L7.40|
000028  4630              MOV      r0,r6                 ;381
00002a  f7fffffe          BL       strlen
00002e  4681              MOV      r9,r0                 ;381
000030  464a              MOV      r2,r9                 ;381
000032  4631              MOV      r1,r6                 ;381
000034  6ca0              LDR      r0,[r4,#0x48]         ;381
000036  f7fffffe          BL       httpd_send
00003a  4605              MOV      r5,r0                 ;381
00003c  b10d              CBZ      r5,|L7.66|
00003e  4628              MOV      r0,r5                 ;384
000040  e7f0              B        |L7.36|
                  |L7.66|
000042  6da0              LDR      r0,[r4,#0x58]         ;389
000044  6840              LDR      r0,[r0,#4]            ;389
000046  b140              CBZ      r0,|L7.90|
000048  6da2              LDR      r2,[r4,#0x58]         ;390
00004a  6851              LDR      r1,[r2,#4]            ;390
00004c  6ca0              LDR      r0,[r4,#0x48]         ;390
00004e  f7fffffe          BL       httpd_send_default_headers
000052  4605              MOV      r5,r0                 ;390
000054  b10d              CBZ      r5,|L7.90|
000056  4628              MOV      r0,r5                 ;393
000058  e7e4              B        |L7.36|
                  |L7.90|
00005a  4816              LDR      r0,|L7.180|
00005c  f7fffffe          BL       strlen
000060  4681              MOV      r9,r0                 ;397
000062  464a              MOV      r2,r9                 ;397
000064  4913              LDR      r1,|L7.180|
000066  6ca0              LDR      r0,[r4,#0x48]         ;397
000068  f7fffffe          BL       httpd_send
00006c  4605              MOV      r5,r0                 ;397
00006e  b10d              CBZ      r5,|L7.116|
000070  4628              MOV      r0,r5                 ;400
000072  e7d7              B        |L7.36|
                  |L7.116|
000074  4642              MOV      r2,r8                 ;403
000076  a110              ADR      r1,|L7.184|
000078  6ca0              LDR      r0,[r4,#0x48]         ;403
00007a  f7fffffe          BL       httpd_send_header
00007e  4605              MOV      r5,r0                 ;403
000080  b10d              CBZ      r5,|L7.134|
000082  4628              MOV      r0,r5                 ;406
000084  e7ce              B        |L7.36|
                  |L7.134|
000086  463b              MOV      r3,r7                 ;412
000088  a20f              ADR      r2,|L7.200|
00008a  2106              MOVS     r1,#6                 ;412
00008c  4668              MOV      r0,sp                 ;412
00008e  f7fffffe          BL       __2snprintf
000092  466a              MOV      r2,sp                 ;414
000094  a10d              ADR      r1,|L7.204|
000096  6ca0              LDR      r0,[r4,#0x48]         ;414
000098  f7fffffe          BL       httpd_send_header
00009c  4605              MOV      r5,r0                 ;414
00009e  b10d              CBZ      r5,|L7.164|
0000a0  4628              MOV      r0,r5                 ;417
0000a2  e7bf              B        |L7.36|
                  |L7.164|
0000a4  2202              MOVS     r2,#2                 ;420
0000a6  a10d              ADR      r1,|L7.220|
0000a8  6ca0              LDR      r0,[r4,#0x48]         ;420
0000aa  f7fffffe          BL       httpd_send
0000ae  4628              MOV      r0,r5                 ;422
0000b0  e7b8              B        |L7.36|
;;;424    
                          ENDP

0000b2  0000              DCW      0x0000
                  |L7.180|
                          DCD      http_header_keep_alive_ctrl
                  |L7.184|
0000b8  436f6e74          DCB      "Content-Type",0
0000bc  656e742d
0000c0  54797065
0000c4  00      
0000c5  00                DCB      0
0000c6  00                DCB      0
0000c7  00                DCB      0
                  |L7.200|
0000c8  256400            DCB      "%d",0
0000cb  00                DCB      0
                  |L7.204|
0000cc  436f6e74          DCB      "Content-Length",0
0000d0  656e742d
0000d4  4c656e67
0000d8  746800  
0000db  00                DCB      0
                  |L7.220|
0000dc  0d0a00            DCB      "\r\n",0
0000df  00                DCB      0

                          AREA ||i.httpd_send_body||, CODE, READONLY, ALIGN=1

                  httpd_send_body PROC
;;;198    
;;;199    int httpd_send_body(int sock, const unsigned char *body_image, uint32_t body_size)
000000  e92d43f0          PUSH     {r4-r9,lr}
;;;200    {
000004  f2ad4d04          SUB      sp,sp,#0x404
000008  4681              MOV      r9,r0
00000a  460e              MOV      r6,r1
00000c  4615              MOV      r5,r2
;;;201      int offset = 0;
00000e  2400              MOVS     r4,#0
;;;202      int ret = kNoErr;
000010  2700              MOVS     r7,#0
;;;203      int buff_size = 0;
000012  46a0              MOV      r8,r4
;;;204      char buff[HTTPD_SEND_BODY_DATA_MAX_LEN];
;;;205    
;;;206      while (body_size > offset)
000014  e01a              B        |L8.76|
                  |L8.22|
;;;207      {
;;;208        buff_size = MIN(HTTPD_SEND_BODY_DATA_MAX_LEN, (body_size - offset));
000016  1b28              SUBS     r0,r5,r4
000018  f5b06f80          CMP      r0,#0x400
00001c  d902              BLS      |L8.36|
00001e  f44f6080          MOV      r0,#0x400
000022  e000              B        |L8.38|
                  |L8.36|
000024  1b28              SUBS     r0,r5,r4
                  |L8.38|
000026  4680              MOV      r8,r0
;;;209        memcpy(buff, &body_image[offset], buff_size);
000028  1931              ADDS     r1,r6,r4
00002a  4642              MOV      r2,r8
00002c  a801              ADD      r0,sp,#4
00002e  f7fffffe          BL       __aeabi_memcpy
;;;210        offset += buff_size;
000032  4444              ADD      r4,r4,r8
;;;211        ret = httpd_send(sock, buff, buff_size);
000034  4642              MOV      r2,r8
000036  a901              ADD      r1,sp,#4
000038  4648              MOV      r0,r9
00003a  f7fffffe          BL       httpd_send
00003e  4607              MOV      r7,r0
;;;212        if(ret != kNoErr)
000040  b127              CBZ      r7,|L8.76|
;;;213          return ret;
000042  4638              MOV      r0,r7
                  |L8.68|
;;;214      }
;;;215      return kNoErr;
;;;216    }
000044  f20d4d04          ADD      sp,sp,#0x404
000048  e8bd83f0          POP      {r4-r9,pc}
                  |L8.76|
00004c  42a5              CMP      r5,r4                 ;206
00004e  d8e2              BHI      |L8.22|
000050  2000              MOVS     r0,#0                 ;215
000052  e7f7              B        |L8.68|
;;;217    
                          ENDP


                          AREA ||i.httpd_send_default_headers||, CODE, READONLY, ALIGN=2

                  httpd_send_default_headers PROC
;;;217    
;;;218    int httpd_send_default_headers(int sock, int hdr_fields)
000000  e92d41f0          PUSH     {r4-r8,lr}
;;;219    {
000004  4606              MOV      r6,r0
000006  460c              MOV      r4,r1
;;;220    	int ret = kNoErr;
000008  2500              MOVS     r5,#0
;;;221    
;;;222    	if (hdr_fields & HTTPD_HDR_ADD_SERVER) {
00000a  f0040001          AND      r0,r4,#1
00000e  b170              CBZ      r0,|L9.46|
;;;223    		ret = httpd_send(sock, http_header_server,
000010  483b              LDR      r0,|L9.256|
000012  f7fffffe          BL       strlen
000016  4607              MOV      r7,r0
000018  463a              MOV      r2,r7
00001a  4939              LDR      r1,|L9.256|
00001c  4630              MOV      r0,r6
00001e  f7fffffe          BL       httpd_send
000022  4605              MOV      r5,r0
;;;224    			strlen(http_header_server));
;;;225    		if (ret != kNoErr)
000024  b11d              CBZ      r5,|L9.46|
;;;226    			return -kInProgressErr;
000026  f04f30ff          MOV      r0,#0xffffffff
                  |L9.42|
;;;227    	}
;;;228    
;;;229    	if (hdr_fields & HTTPD_HDR_ADD_CONN_CLOSE) {
;;;230    		ret = httpd_send(sock, http_header_conn_close,
;;;231    			strlen(http_header_conn_close));
;;;232    		if (ret != kNoErr)
;;;233    			return -kInProgressErr;
;;;234    	}
;;;235    
;;;236    	if (hdr_fields & HTTPD_HDR_ADD_CONN_KEEP_ALIVE) {
;;;237    		ret = httpd_send(sock, http_header_conn_keep_alive,
;;;238    			strlen(http_header_conn_keep_alive));
;;;239    		if (ret != kNoErr)
;;;240    			return -kInProgressErr;
;;;241    	}
;;;242    
;;;243    	/* Currently as we are sending chunked data, this is mandatory */
;;;244    	if (hdr_fields & HTTPD_HDR_ADD_TYPE_CHUNKED) {
;;;245    		ret = httpd_send(sock, http_header_type_chunked,
;;;246    			strlen(http_header_type_chunked));
;;;247    		if (ret != kNoErr)
;;;248    			return -kInProgressErr;
;;;249    	}
;;;250    
;;;251    	if (hdr_fields & HTTPD_HDR_ADD_CACHE_CTRL) {
;;;252    		ret = httpd_send(sock, http_header_cache_ctrl,
;;;253    			strlen(http_header_cache_ctrl));
;;;254    		if (ret != kNoErr)
;;;255    			return -kInProgressErr;
;;;256    	}
;;;257    
;;;258    	if (hdr_fields & HTTPD_HDR_ADD_CACHE_CTRL_NO_CHK) {
;;;259    		ret = httpd_send(sock, http_header_cache_ctrl_no_chk,
;;;260    			strlen(http_header_cache_ctrl_no_chk));
;;;261    		if (ret != kNoErr)
;;;262    			return -kInProgressErr;
;;;263    	}
;;;264    
;;;265    	if (hdr_fields & HTTPD_HDR_ADD_PRAGMA_NO_CACHE) {
;;;266    		ret = httpd_send(sock, http_header_pragma_no_cache,
;;;267    			strlen(http_header_pragma_no_cache));
;;;268    		if (ret != kNoErr)
;;;269    			return -kInProgressErr;
;;;270    	}
;;;271    
;;;272    	return kNoErr;
;;;273    }
00002a  e8bd81f0          POP      {r4-r8,pc}
                  |L9.46|
00002e  f0040004          AND      r0,r4,#4              ;229
000032  b168              CBZ      r0,|L9.80|
000034  4833              LDR      r0,|L9.260|
000036  f7fffffe          BL       strlen
00003a  4607              MOV      r7,r0                 ;230
00003c  463a              MOV      r2,r7                 ;230
00003e  4931              LDR      r1,|L9.260|
000040  4630              MOV      r0,r6                 ;230
000042  f7fffffe          BL       httpd_send
000046  4605              MOV      r5,r0                 ;230
000048  b115              CBZ      r5,|L9.80|
00004a  f04f30ff          MOV      r0,#0xffffffff        ;233
00004e  e7ec              B        |L9.42|
                  |L9.80|
000050  f0040002          AND      r0,r4,#2              ;236
000054  b168              CBZ      r0,|L9.114|
000056  482c              LDR      r0,|L9.264|
000058  f7fffffe          BL       strlen
00005c  4607              MOV      r7,r0                 ;237
00005e  463a              MOV      r2,r7                 ;237
000060  4929              LDR      r1,|L9.264|
000062  4630              MOV      r0,r6                 ;237
000064  f7fffffe          BL       httpd_send
000068  4605              MOV      r5,r0                 ;237
00006a  b115              CBZ      r5,|L9.114|
00006c  f04f30ff          MOV      r0,#0xffffffff        ;240
000070  e7db              B        |L9.42|
                  |L9.114|
000072  f0040008          AND      r0,r4,#8              ;244
000076  b168              CBZ      r0,|L9.148|
000078  4824              LDR      r0,|L9.268|
00007a  f7fffffe          BL       strlen
00007e  4607              MOV      r7,r0                 ;245
000080  463a              MOV      r2,r7                 ;245
000082  4922              LDR      r1,|L9.268|
000084  4630              MOV      r0,r6                 ;245
000086  f7fffffe          BL       httpd_send
00008a  4605              MOV      r5,r0                 ;245
00008c  b115              CBZ      r5,|L9.148|
00008e  f04f30ff          MOV      r0,#0xffffffff        ;248
000092  e7ca              B        |L9.42|
                  |L9.148|
000094  f0040010          AND      r0,r4,#0x10           ;251
000098  b168              CBZ      r0,|L9.182|
00009a  481d              LDR      r0,|L9.272|
00009c  f7fffffe          BL       strlen
0000a0  4607              MOV      r7,r0                 ;252
0000a2  463a              MOV      r2,r7                 ;252
0000a4  491a              LDR      r1,|L9.272|
0000a6  4630              MOV      r0,r6                 ;252
0000a8  f7fffffe          BL       httpd_send
0000ac  4605              MOV      r5,r0                 ;252
0000ae  b115              CBZ      r5,|L9.182|
0000b0  f04f30ff          MOV      r0,#0xffffffff        ;255
0000b4  e7b9              B        |L9.42|
                  |L9.182|
0000b6  f0040020          AND      r0,r4,#0x20           ;258
0000ba  b168              CBZ      r0,|L9.216|
0000bc  4815              LDR      r0,|L9.276|
0000be  f7fffffe          BL       strlen
0000c2  4607              MOV      r7,r0                 ;259
0000c4  463a              MOV      r2,r7                 ;259
0000c6  4913              LDR      r1,|L9.276|
0000c8  4630              MOV      r0,r6                 ;259
0000ca  f7fffffe          BL       httpd_send
0000ce  4605              MOV      r5,r0                 ;259
0000d0  b115              CBZ      r5,|L9.216|
0000d2  f04f30ff          MOV      r0,#0xffffffff        ;262
0000d6  e7a8              B        |L9.42|
                  |L9.216|
0000d8  f0040040          AND      r0,r4,#0x40           ;265
0000dc  b168              CBZ      r0,|L9.250|
0000de  480e              LDR      r0,|L9.280|
0000e0  f7fffffe          BL       strlen
0000e4  4607              MOV      r7,r0                 ;266
0000e6  463a              MOV      r2,r7                 ;266
0000e8  490b              LDR      r1,|L9.280|
0000ea  4630              MOV      r0,r6                 ;266
0000ec  f7fffffe          BL       httpd_send
0000f0  4605              MOV      r5,r0                 ;266
0000f2  b115              CBZ      r5,|L9.250|
0000f4  f04f30ff          MOV      r0,#0xffffffff        ;269
0000f8  e797              B        |L9.42|
                  |L9.250|
0000fa  2000              MOVS     r0,#0                 ;272
0000fc  e795              B        |L9.42|
;;;274    
                          ENDP

0000fe  0000              DCW      0x0000
                  |L9.256|
                          DCD      http_header_server
                  |L9.260|
                          DCD      http_header_conn_close
                  |L9.264|
                          DCD      http_header_conn_keep_alive
                  |L9.268|
                          DCD      http_header_type_chunked
                  |L9.272|
                          DCD      http_header_cache_ctrl
                  |L9.276|
                          DCD      http_header_cache_ctrl_no_chk
                  |L9.280|
                          DCD      http_header_pragma_no_cache

                          AREA ||i.httpd_send_header||, CODE, READONLY, ALIGN=2

                  httpd_send_header PROC
;;;177    
;;;178    int httpd_send_header(int sock, const char *name, const char *value)
000000  e92d41f0          PUSH     {r4-r8,lr}
;;;179    {
000004  4607              MOV      r7,r0
000006  460e              MOV      r6,r1
000008  4615              MOV      r5,r2
;;;180    
;;;181    	int ret;
;;;182    
;;;183    	ret = httpd_send(sock, name, strlen(name));
00000a  4630              MOV      r0,r6
00000c  f7fffffe          BL       strlen
000010  4680              MOV      r8,r0
000012  4642              MOV      r2,r8
000014  4631              MOV      r1,r6
000016  4638              MOV      r0,r7
000018  f7fffffe          BL       httpd_send
00001c  4604              MOV      r4,r0
;;;184    	if (ret)
00001e  b114              CBZ      r4,|L10.38|
;;;185    		return ret;
000020  4620              MOV      r0,r4
                  |L10.34|
;;;186    	ret = httpd_send(sock, ": ", 2);
;;;187    	if (ret)
;;;188    		return ret;
;;;189    	ret = httpd_send(sock, value, strlen(value));
;;;190    	if (ret)
;;;191    		return ret;
;;;192    	ret = httpd_send_crlf(sock);
;;;193    	if (ret)
;;;194    		return ret;
;;;195    
;;;196    	return kNoErr;
;;;197    }
000022  e8bd81f0          POP      {r4-r8,pc}
                  |L10.38|
000026  2202              MOVS     r2,#2                 ;186
000028  a10f              ADR      r1,|L10.104|
00002a  4638              MOV      r0,r7                 ;186
00002c  f7fffffe          BL       httpd_send
000030  4604              MOV      r4,r0                 ;186
000032  b10c              CBZ      r4,|L10.56|
000034  4620              MOV      r0,r4                 ;188
000036  e7f4              B        |L10.34|
                  |L10.56|
000038  4628              MOV      r0,r5                 ;189
00003a  f7fffffe          BL       strlen
00003e  4680              MOV      r8,r0                 ;189
000040  4642              MOV      r2,r8                 ;189
000042  4629              MOV      r1,r5                 ;189
000044  4638              MOV      r0,r7                 ;189
000046  f7fffffe          BL       httpd_send
00004a  4604              MOV      r4,r0                 ;189
00004c  b10c              CBZ      r4,|L10.82|
00004e  4620              MOV      r0,r4                 ;191
000050  e7e7              B        |L10.34|
                  |L10.82|
000052  2202              MOVS     r2,#2                 ;192
000054  a105              ADR      r1,|L10.108|
000056  4638              MOV      r0,r7                 ;192
000058  f7fffffe          BL       httpd_send
00005c  4604              MOV      r4,r0                 ;192
00005e  b10c              CBZ      r4,|L10.100|
000060  4620              MOV      r0,r4                 ;194
000062  e7de              B        |L10.34|
                  |L10.100|
000064  2000              MOVS     r0,#0                 ;196
000066  e7dc              B        |L10.34|
;;;198    
                          ENDP

                  |L10.104|
000068  3a2000            DCB      ": ",0
00006b  00                DCB      0
                  |L10.108|
00006c  0d0a00            DCB      "\r\n",0
00006f  00                DCB      0

                          AREA ||i.httpd_send_response||, CODE, READONLY, ALIGN=2

                          REQUIRE _printf_percent
                          REQUIRE _printf_d
                          REQUIRE _printf_int_dec
                  httpd_send_response PROC
;;;424    
;;;425    int httpd_send_response(httpd_request_t *req, const char *first_line,
000000  e92d47fc          PUSH     {r2-r10,lr}
;;;426    			char *content, int length, const char *content_type)
;;;427    {
000004  4604              MOV      r4,r0
000006  460e              MOV      r6,r1
000008  4617              MOV      r7,r2
00000a  4698              MOV      r8,r3
00000c  f8dd9028          LDR      r9,[sp,#0x28]
;;;428    	int ret;
;;;429    
;;;430    	/* Parse the header tags. This is valid only for GET or HEAD request */
;;;431    	if (req->type == HTTPD_REQ_TYPE_GET ||
000010  6820              LDR      r0,[r4,#0]
000012  2802              CMP      r0,#2
000014  d002              BEQ      |L11.28|
;;;432    		req->type == HTTPD_REQ_TYPE_HEAD) {
000016  6820              LDR      r0,[r4,#0]
000018  2810              CMP      r0,#0x10
00001a  d107              BNE      |L11.44|
                  |L11.28|
;;;433    		ret = httpd_purge_headers(req->sock);
00001c  6ca0              LDR      r0,[r4,#0x48]
00001e  f7fffffe          BL       httpd_purge_headers
000022  4605              MOV      r5,r0
;;;434    
;;;435    		if (ret != kNoErr) {
000024  b115              CBZ      r5,|L11.44|
;;;436    			httpd_d("Unable to purge headers");
;;;437    			return ret;
000026  4628              MOV      r0,r5
                  |L11.40|
;;;438    		}
;;;439    	}
;;;440    
;;;441    	ret = httpd_send(req->sock, first_line, strlen(first_line));
;;;442    	if (ret != kNoErr) {
;;;443    		httpd_d("Error in sending the first line");
;;;444    		return ret;
;;;445    	}
;;;446    
;;;447    	/* Send default headers */
;;;448    	httpd_d("HTTP Req for URI %s", req->wsgi->uri);
;;;449    	if (req->wsgi->hdr_fields) {
;;;450    		ret = httpd_send_default_headers(req->sock,
;;;451    				req->wsgi->hdr_fields);
;;;452    		if (ret != kNoErr) {
;;;453    			httpd_d("Error in sending default headers");
;;;454    			return ret;
;;;455    		}
;;;456    	}
;;;457    	ret = httpd_send_header(req->sock, "Content-Type", content_type);
;;;458    	if (ret != kNoErr) {
;;;459    		httpd_d("Error in sending Content-Type");
;;;460    		return ret;
;;;461    	}
;;;462    
;;;463    	/* Send Content-Length if non-chunked */
;;;464    	if (!chunked_encoding(req)) {
;;;465    		/* 6 should be more than enough */
;;;466    		char con_len[6];
;;;467    		snprintf(con_len, sizeof(con_len), "%d", length);
;;;468    
;;;469    		ret = httpd_send_header(req->sock, "Content-Length", con_len);
;;;470    		if (ret != kNoErr) {
;;;471    			httpd_d("Error in sending Content-Length");
;;;472    			return ret;
;;;473    		}
;;;474    	}
;;;475    
;;;476    	httpd_send_crlf(req->sock);
;;;477    
;;;478    	/* HTTP Head response does not require any content. It should
;;;479    	 * contain identical headers as per the corresponding GET request */
;;;480    	if (req->type != HTTPD_REQ_TYPE_HEAD) {
;;;481    		if (chunked_encoding(req)) {
;;;482    			ret = httpd_send_chunk(req->sock, content, length);
;;;483    			if (ret != kNoErr) {
;;;484    				httpd_d("Error in sending response content");
;;;485    				return ret;
;;;486    			}
;;;487    
;;;488    			ret = httpd_send_chunk(req->sock, NULL, 0);
;;;489    			if (ret != kNoErr)
;;;490    				httpd_d("Error in sending last chunk");
;;;491    		} else {
;;;492    			/* Send our data */
;;;493    			ret = httpd_send(req->sock, content, length);
;;;494    			if (ret != kNoErr)
;;;495    				httpd_d("Error sending response");
;;;496    		}
;;;497    	}
;;;498    	return ret;
;;;499    }
000028  e8bd87fc          POP      {r2-r10,pc}
                  |L11.44|
00002c  4630              MOV      r0,r6                 ;441
00002e  f7fffffe          BL       strlen
000032  4682              MOV      r10,r0                ;441
000034  4652              MOV      r2,r10                ;441
000036  4631              MOV      r1,r6                 ;441
000038  6ca0              LDR      r0,[r4,#0x48]         ;441
00003a  f7fffffe          BL       httpd_send
00003e  4605              MOV      r5,r0                 ;441
000040  b10d              CBZ      r5,|L11.70|
000042  4628              MOV      r0,r5                 ;444
000044  e7f0              B        |L11.40|
                  |L11.70|
000046  6da0              LDR      r0,[r4,#0x58]         ;449
000048  6840              LDR      r0,[r0,#4]            ;449
00004a  b140              CBZ      r0,|L11.94|
00004c  6da2              LDR      r2,[r4,#0x58]         ;450
00004e  6851              LDR      r1,[r2,#4]            ;450
000050  6ca0              LDR      r0,[r4,#0x48]         ;450
000052  f7fffffe          BL       httpd_send_default_headers
000056  4605              MOV      r5,r0                 ;450
000058  b10d              CBZ      r5,|L11.94|
00005a  4628              MOV      r0,r5                 ;454
00005c  e7e4              B        |L11.40|
                  |L11.94|
00005e  464a              MOV      r2,r9                 ;457
000060  a120              ADR      r1,|L11.228|
000062  6ca0              LDR      r0,[r4,#0x48]         ;457
000064  f7fffffe          BL       httpd_send_header
000068  4605              MOV      r5,r0                 ;457
00006a  b10d              CBZ      r5,|L11.112|
00006c  4628              MOV      r0,r5                 ;460
00006e  e7db              B        |L11.40|
                  |L11.112|
000070  4620              MOV      r0,r4                 ;464
000072  f7fffffe          BL       chunked_encoding
000076  b978              CBNZ     r0,|L11.152|
000078  4643              MOV      r3,r8                 ;467
00007a  a21e              ADR      r2,|L11.244|
00007c  2106              MOVS     r1,#6                 ;467
00007e  4668              MOV      r0,sp                 ;467
000080  f7fffffe          BL       __2snprintf
000084  466a              MOV      r2,sp                 ;469
000086  a11c              ADR      r1,|L11.248|
000088  6ca0              LDR      r0,[r4,#0x48]         ;469
00008a  f7fffffe          BL       httpd_send_header
00008e  4605              MOV      r5,r0                 ;469
000090  b10d              CBZ      r5,|L11.150|
000092  4628              MOV      r0,r5                 ;472
000094  e7c8              B        |L11.40|
                  |L11.150|
000096  bf00              NOP                            ;474
                  |L11.152|
000098  2202              MOVS     r2,#2                 ;476
00009a  a11b              ADR      r1,|L11.264|
00009c  6ca0              LDR      r0,[r4,#0x48]         ;476
00009e  f7fffffe          BL       httpd_send
0000a2  6820              LDR      r0,[r4,#0]            ;480
0000a4  2810              CMP      r0,#0x10              ;480
0000a6  d01a              BEQ      |L11.222|
0000a8  4620              MOV      r0,r4                 ;481
0000aa  f7fffffe          BL       chunked_encoding
0000ae  b178              CBZ      r0,|L11.208|
0000b0  4642              MOV      r2,r8                 ;482
0000b2  4639              MOV      r1,r7                 ;482
0000b4  6ca0              LDR      r0,[r4,#0x48]         ;482
0000b6  f7fffffe          BL       httpd_send_chunk
0000ba  4605              MOV      r5,r0                 ;482
0000bc  b10d              CBZ      r5,|L11.194|
0000be  4628              MOV      r0,r5                 ;485
0000c0  e7b2              B        |L11.40|
                  |L11.194|
0000c2  2200              MOVS     r2,#0                 ;488
0000c4  4611              MOV      r1,r2                 ;488
0000c6  6ca0              LDR      r0,[r4,#0x48]         ;488
0000c8  f7fffffe          BL       httpd_send_chunk
0000cc  4605              MOV      r5,r0                 ;488
0000ce  e006              B        |L11.222|
                  |L11.208|
0000d0  4642              MOV      r2,r8                 ;493
0000d2  4639              MOV      r1,r7                 ;493
0000d4  6ca0              LDR      r0,[r4,#0x48]         ;493
0000d6  f7fffffe          BL       httpd_send
0000da  4605              MOV      r5,r0                 ;493
0000dc  bf00              NOP                            ;494
                  |L11.222|
0000de  4628              MOV      r0,r5                 ;498
0000e0  e7a2              B        |L11.40|
;;;500    int httpd_get_data(httpd_request_t *req, char *content, int length)
                          ENDP

0000e2  0000              DCW      0x0000
                  |L11.228|
0000e4  436f6e74          DCB      "Content-Type",0
0000e8  656e742d
0000ec  54797065
0000f0  00      
0000f1  00                DCB      0
0000f2  00                DCB      0
0000f3  00                DCB      0
                  |L11.244|
0000f4  256400            DCB      "%d",0
0000f7  00                DCB      0
                  |L11.248|
0000f8  436f6e74          DCB      "Content-Length",0
0000fc  656e742d
000100  4c656e67
000104  746800  
000107  00                DCB      0
                  |L11.264|
000108  0d0a00            DCB      "\r\n",0
00010b  00                DCB      0

                          AREA ||i.httpd_send_response_301||, CODE, READONLY, ALIGN=2

                          REQUIRE _printf_percent
                          REQUIRE _printf_d
                          REQUIRE _printf_int_dec
                  httpd_send_response_301 PROC
;;;280    
;;;281    int httpd_send_response_301(httpd_request_t *req, char *location, const char
000000  e92d47fc          PUSH     {r2-r10,lr}
;;;282    		*content_type, char *content, int content_len)
;;;283    {
000004  4604              MOV      r4,r0
000006  460f              MOV      r7,r1
000008  4691              MOV      r9,r2
00000a  461e              MOV      r6,r3
00000c  f8dd8028          LDR      r8,[sp,#0x28]
;;;284    	int ret;
;;;285    
;;;286    	/* Parse the header tags. This is valid only for GET or HEAD request */
;;;287    	if (req->type == HTTPD_REQ_TYPE_GET ||
000010  6820              LDR      r0,[r4,#0]
000012  2802              CMP      r0,#2
000014  d002              BEQ      |L12.28|
;;;288    		req->type == HTTPD_REQ_TYPE_HEAD) {
000016  6820              LDR      r0,[r4,#0]
000018  2810              CMP      r0,#0x10
00001a  d107              BNE      |L12.44|
                  |L12.28|
;;;289    		ret = httpd_purge_headers(req->sock);
00001c  6ca0              LDR      r0,[r4,#0x48]
00001e  f7fffffe          BL       httpd_purge_headers
000022  4605              MOV      r5,r0
;;;290    
;;;291    		if (ret != kNoErr) {
000024  b115              CBZ      r5,|L12.44|
;;;292    			httpd_d("Unable to purge headers");
;;;293    			return ret;
000026  4628              MOV      r0,r5
                  |L12.40|
;;;294    		}
;;;295    	}
;;;296    
;;;297    	ret = httpd_send(req->sock, HTTP_RES_301, strlen(HTTP_RES_301));
;;;298    	if (ret != kNoErr) {
;;;299    		httpd_d("Error in sending the first line");
;;;300    		return ret;
;;;301    	}
;;;302    
;;;303    	/* Send default headers */
;;;304    	httpd_d("HTTP Req for URI %s", req->wsgi->uri);
;;;305    	if (req->wsgi->hdr_fields) {
;;;306    		ret = httpd_send_default_headers(req->sock,
;;;307    				req->wsgi->hdr_fields);
;;;308    		if (ret != kNoErr) {
;;;309    			httpd_d("Error in sending default headers");
;;;310    			return ret;
;;;311    		}
;;;312    	}
;;;313    	ret = httpd_send_header(req->sock, "Location", location);
;;;314    	if (ret != kNoErr) {
;;;315    		httpd_d("Error in sending Location");
;;;316    		return ret;
;;;317    	}
;;;318    
;;;319    	ret = httpd_send_header(req->sock, "Content-Type", content_type);
;;;320    	if (ret != kNoErr) {
;;;321    		httpd_d("Error in sending Content-Type");
;;;322    		return ret;
;;;323    	}
;;;324    
;;;325    	/* Send Content-Length if non-chunked */
;;;326    	if (!chunked_encoding(req)) {
;;;327    		/* 6 should be more than enough */
;;;328    		char con_len[6];
;;;329    		snprintf(con_len, sizeof(con_len), "%d", content_len);
;;;330    
;;;331    		ret = httpd_send_header(req->sock, "Content-Length", con_len);
;;;332    		if (ret != kNoErr) {
;;;333    			httpd_d("Error in sending Content-Length");
;;;334    			return ret;
;;;335    		}
;;;336    	}
;;;337    
;;;338    	httpd_send_crlf(req->sock);
;;;339    
;;;340    	/* Content can be NULL */
;;;341    	if (!content)
;;;342    		return kNoErr;
;;;343    	/* HTTP Head response does not require any content. It should
;;;344    	 * contain identical headers as per the corresponding GET request */
;;;345    	if (req->type != HTTPD_REQ_TYPE_HEAD) {
;;;346    		if (chunked_encoding(req)) {
;;;347    			ret = httpd_send_chunk(req->sock, content, content_len);
;;;348    			if (ret != kNoErr) {
;;;349    				httpd_d("Error in sending response content");
;;;350    				return ret;
;;;351    			}
;;;352    
;;;353    			ret = httpd_send_chunk(req->sock, NULL, 0);
;;;354    			if (ret != kNoErr)
;;;355    				httpd_d("Error in sending last chunk");
;;;356    		} else {
;;;357    			/* Send our data */
;;;358    			ret = httpd_send(req->sock, content, content_len);
;;;359    			if (ret != kNoErr)
;;;360    				httpd_d("Error sending response");
;;;361    		}
;;;362    	}
;;;363    	return ret;
;;;364    }
000028  e8bd87fc          POP      {r2-r10,pc}
                  |L12.44|
00002c  2220              MOVS     r2,#0x20              ;297
00002e  a131              ADR      r1,|L12.244|
000030  6ca0              LDR      r0,[r4,#0x48]         ;297
000032  f7fffffe          BL       httpd_send
000036  4605              MOV      r5,r0                 ;297
000038  b10d              CBZ      r5,|L12.62|
00003a  4628              MOV      r0,r5                 ;300
00003c  e7f4              B        |L12.40|
                  |L12.62|
00003e  6da0              LDR      r0,[r4,#0x58]         ;305
000040  6840              LDR      r0,[r0,#4]            ;305
000042  b140              CBZ      r0,|L12.86|
000044  6da2              LDR      r2,[r4,#0x58]         ;306
000046  6851              LDR      r1,[r2,#4]            ;306
000048  6ca0              LDR      r0,[r4,#0x48]         ;306
00004a  f7fffffe          BL       httpd_send_default_headers
00004e  4605              MOV      r5,r0                 ;306
000050  b10d              CBZ      r5,|L12.86|
000052  4628              MOV      r0,r5                 ;310
000054  e7e8              B        |L12.40|
                  |L12.86|
000056  463a              MOV      r2,r7                 ;313
000058  a12f              ADR      r1,|L12.280|
00005a  6ca0              LDR      r0,[r4,#0x48]         ;313
00005c  f7fffffe          BL       httpd_send_header
000060  4605              MOV      r5,r0                 ;313
000062  b10d              CBZ      r5,|L12.104|
000064  4628              MOV      r0,r5                 ;316
000066  e7df              B        |L12.40|
                  |L12.104|
000068  464a              MOV      r2,r9                 ;319
00006a  a12e              ADR      r1,|L12.292|
00006c  6ca0              LDR      r0,[r4,#0x48]         ;319
00006e  f7fffffe          BL       httpd_send_header
000072  4605              MOV      r5,r0                 ;319
000074  b10d              CBZ      r5,|L12.122|
000076  4628              MOV      r0,r5                 ;322
000078  e7d6              B        |L12.40|
                  |L12.122|
00007a  4620              MOV      r0,r4                 ;326
00007c  f7fffffe          BL       chunked_encoding
000080  b978              CBNZ     r0,|L12.162|
000082  4643              MOV      r3,r8                 ;329
000084  a22b              ADR      r2,|L12.308|
000086  2106              MOVS     r1,#6                 ;329
000088  4668              MOV      r0,sp                 ;329
00008a  f7fffffe          BL       __2snprintf
00008e  466a              MOV      r2,sp                 ;331
000090  a129              ADR      r1,|L12.312|
000092  6ca0              LDR      r0,[r4,#0x48]         ;331
000094  f7fffffe          BL       httpd_send_header
000098  4605              MOV      r5,r0                 ;331
00009a  b10d              CBZ      r5,|L12.160|
00009c  4628              MOV      r0,r5                 ;334
00009e  e7c3              B        |L12.40|
                  |L12.160|
0000a0  bf00              NOP                            ;336
                  |L12.162|
0000a2  2202              MOVS     r2,#2                 ;338
0000a4  a128              ADR      r1,|L12.328|
0000a6  6ca0              LDR      r0,[r4,#0x48]         ;338
0000a8  f7fffffe          BL       httpd_send
0000ac  b90e              CBNZ     r6,|L12.178|
0000ae  2000              MOVS     r0,#0                 ;342
0000b0  e7ba              B        |L12.40|
                  |L12.178|
0000b2  6820              LDR      r0,[r4,#0]            ;345
0000b4  2810              CMP      r0,#0x10              ;345
0000b6  d01a              BEQ      |L12.238|
0000b8  4620              MOV      r0,r4                 ;346
0000ba  f7fffffe          BL       chunked_encoding
0000be  b178              CBZ      r0,|L12.224|
0000c0  4642              MOV      r2,r8                 ;347
0000c2  4631              MOV      r1,r6                 ;347
0000c4  6ca0              LDR      r0,[r4,#0x48]         ;347
0000c6  f7fffffe          BL       httpd_send_chunk
0000ca  4605              MOV      r5,r0                 ;347
0000cc  b10d              CBZ      r5,|L12.210|
0000ce  4628              MOV      r0,r5                 ;350
0000d0  e7aa              B        |L12.40|
                  |L12.210|
0000d2  2200              MOVS     r2,#0                 ;353
0000d4  4611              MOV      r1,r2                 ;353
0000d6  6ca0              LDR      r0,[r4,#0x48]         ;353
0000d8  f7fffffe          BL       httpd_send_chunk
0000dc  4605              MOV      r5,r0                 ;353
0000de  e006              B        |L12.238|
                  |L12.224|
0000e0  4642              MOV      r2,r8                 ;358
0000e2  4631              MOV      r1,r6                 ;358
0000e4  6ca0              LDR      r0,[r4,#0x48]         ;358
0000e6  f7fffffe          BL       httpd_send
0000ea  4605              MOV      r5,r0                 ;358
0000ec  bf00              NOP                            ;359
                  |L12.238|
0000ee  4628              MOV      r0,r5                 ;363
0000f0  e79a              B        |L12.40|
;;;365    
                          ENDP

0000f2  0000              DCW      0x0000
                  |L12.244|
0000f4  48545450          DCB      "HTTP/1.1 301 Moved Permanently\r\n",0
0000f8  2f312e31
0000fc  20333031
000100  204d6f76
000104  65642050
000108  65726d61
00010c  6e656e74
000110  6c790d0a
000114  00      
000115  00                DCB      0
000116  00                DCB      0
000117  00                DCB      0
                  |L12.280|
000118  4c6f6361          DCB      "Location",0
00011c  74696f6e
000120  00      
000121  00                DCB      0
000122  00                DCB      0
000123  00                DCB      0
                  |L12.292|
000124  436f6e74          DCB      "Content-Type",0
000128  656e742d
00012c  54797065
000130  00      
000131  00                DCB      0
000132  00                DCB      0
000133  00                DCB      0
                  |L12.308|
000134  256400            DCB      "%d",0
000137  00                DCB      0
                  |L12.312|
000138  436f6e74          DCB      "Content-Length",0
00013c  656e742d
000140  4c656e67
000144  746800  
000147  00                DCB      0
                  |L12.328|
000148  0d0a00            DCB      "\r\n",0
00014b  00                DCB      0

                          AREA ||i.httpd_skip_absolute_http_path||, CODE, READONLY, ALIGN=2

                  httpd_skip_absolute_http_path PROC
;;;558    /* Function to skip the initial ipaddress/hostname path in a URL */
;;;559    char *httpd_skip_absolute_http_path(char *request)
000000  b510              PUSH     {r4,lr}
;;;560    {
000002  4604              MOV      r4,r0
;;;561    #define ABS_HTTP_PATH "http://"
;;;562    	if (!strcmp(request, ABS_HTTP_PATH)) {
000004  a107              ADR      r1,|L13.36|
000006  4620              MOV      r0,r4
000008  f7fffffe          BL       strcmp
00000c  b938              CBNZ     r0,|L13.30|
;;;563    		/* This is a full path request instead of just the absolute
;;;564    		 * path. Skip the initial, ipaddress/hostname part */
;;;565    		request += strlen(ABS_HTTP_PATH);
00000e  1de4              ADDS     r4,r4,#7
;;;566    		/* fixme: this while loop outside the if block?
;;;567    		 * if IP address without http:// is entered? */
;;;568    		while (*request && *request != '/')
000010  e000              B        |L13.20|
                  |L13.18|
;;;569    			request++;
000012  1c64              ADDS     r4,r4,#1
                  |L13.20|
000014  7820              LDRB     r0,[r4,#0]            ;568
000016  b110              CBZ      r0,|L13.30|
000018  7820              LDRB     r0,[r4,#0]            ;568
00001a  282f              CMP      r0,#0x2f              ;568
00001c  d1f9              BNE      |L13.18|
                  |L13.30|
;;;570    	}
;;;571    	httpd_d("The request is %s", request);
;;;572    	return request;
00001e  4620              MOV      r0,r4
;;;573    }
000020  bd10              POP      {r4,pc}
;;;574    
                          ENDP

000022  0000              DCW      0x0000
                  |L13.36|
000024  68747470          DCB      "http://",0
000028  3a2f2f00

                          AREA ||i.httpd_unregister_wsgi_handler||, CODE, READONLY, ALIGN=2

                  httpd_unregister_wsgi_handler PROC
;;;104    /* Unregister a WSGI call */
;;;105    int httpd_unregister_wsgi_handler(struct httpd_wsgi_call *wsgi_call)
000000  4602              MOV      r2,r0
;;;106    {
;;;107    	int i;
;;;108    
;;;109    	for (i = 0; i < MAX_WSGI_HANDLERS; i++) {
000002  2100              MOVS     r1,#0
000004  e00e              B        |L14.36|
                  |L14.6|
;;;110    		if (calls[i] && (calls[i] == wsgi_call)) {
000006  4809              LDR      r0,|L14.44|
000008  f8500021          LDR      r0,[r0,r1,LSL #2]
00000c  b148              CBZ      r0,|L14.34|
00000e  4807              LDR      r0,|L14.44|
000010  f8500021          LDR      r0,[r0,r1,LSL #2]
000014  4290              CMP      r0,r2
000016  d104              BNE      |L14.34|
;;;111    			calls[i] = NULL;
000018  2000              MOVS     r0,#0
00001a  4b04              LDR      r3,|L14.44|
00001c  f8430021          STR      r0,[r3,r1,LSL #2]
                  |L14.32|
;;;112    			return 0;
;;;113    		}
;;;114    	}
;;;115    
;;;116    	return 0;
;;;117    }
000020  4770              BX       lr
                  |L14.34|
000022  1c49              ADDS     r1,r1,#1              ;109
                  |L14.36|
000024  2920              CMP      r1,#0x20              ;109
000026  dbee              BLT      |L14.6|
000028  2000              MOVS     r0,#0                 ;116
00002a  e7f9              B        |L14.32|
;;;118    
                          ENDP

                  |L14.44|
                          DCD      calls

                          AREA ||i.httpd_unregister_wsgi_handlers||, CODE, READONLY, ALIGN=1

                  httpd_unregister_wsgi_handlers PROC
;;;118    
;;;119    int httpd_unregister_wsgi_handlers(struct httpd_wsgi_call *wsgi_call_list,
000000  e92d41f0          PUSH     {r4-r8,lr}
;;;120    				int handlers_no)
;;;121    {
000004  4606              MOV      r6,r0
000006  460f              MOV      r7,r1
;;;122    	int i, ret, err = 0;
000008  f04f0800          MOV      r8,#0
;;;123    
;;;124    	for (i = 0; i < handlers_no; i++) {
00000c  2400              MOVS     r4,#0
00000e  e00a              B        |L15.38|
                  |L15.16|
;;;125    		ret = httpd_unregister_wsgi_handler(&wsgi_call_list[i]);
000010  ebc401c4          RSB      r1,r4,r4,LSL #3
000014  eb060081          ADD      r0,r6,r1,LSL #2
000018  f7fffffe          BL       httpd_unregister_wsgi_handler
00001c  4605              MOV      r5,r0
;;;126    		if (ret != kNoErr) {
00001e  b10d              CBZ      r5,|L15.36|
;;;127    			httpd_d("Error in unregistering handler\r\n");
;;;128    			err++;
000020  f1080801          ADD      r8,r8,#1
                  |L15.36|
000024  1c64              ADDS     r4,r4,#1              ;124
                  |L15.38|
000026  42bc              CMP      r4,r7                 ;124
000028  dbf2              BLT      |L15.16|
;;;129    		}
;;;130    	}
;;;131    	if (err)
00002a  f1b80f00          CMP      r8,#0
00002e  d003              BEQ      |L15.56|
;;;132    		return -kInProgressErr;
000030  f04f30ff          MOV      r0,#0xffffffff
                  |L15.52|
;;;133    	else
;;;134    		return kNoErr;
;;;135    }
000034  e8bd81f0          POP      {r4-r8,pc}
                  |L15.56|
000038  2000              MOVS     r0,#0                 ;134
00003a  e7fb              B        |L15.52|
;;;136    
                          ENDP


                          AREA ||i.httpd_validate_uri||, CODE, READONLY, ALIGN=1

                  httpd_validate_uri PROC
;;;575    /* Match the request URI against the one that is registered with us. */
;;;576    int httpd_validate_uri(char *req, const char *api, int flags)
000000  b570              PUSH     {r4-r6,lr}
;;;577    {
000002  4603              MOV      r3,r0
000004  460c              MOV      r4,r1
000006  4615              MOV      r5,r2
;;;578    	unsigned char *c1 = (unsigned char *)req;
000008  4619              MOV      r1,r3
;;;579    	unsigned char *c2 = (unsigned char *)api;
00000a  4622              MOV      r2,r4
;;;580    
;;;581    /* The 'api' contains our reference copy, the 'req' is sent by the user. It may
;;;582     * have additional characters in the front. Let us make sure if 'req' contains
;;;583     * exactly the same characters as the api first, then lets make exceptions if
;;;584     * any.
;;;585     */
;;;586    	while (*c2) {
00000c  e008              B        |L16.32|
                  |L16.14|
;;;587    		if (*c1 != *c2)
00000e  7808              LDRB     r0,[r1,#0]
000010  7816              LDRB     r6,[r2,#0]
000012  42b0              CMP      r0,r6
000014  d002              BEQ      |L16.28|
;;;588    			return -1;
000016  f04f30ff          MOV      r0,#0xffffffff
                  |L16.26|
;;;589    		c1++;
;;;590    		c2++;
;;;591    	}
;;;592    
;;;593    	if (flags & APP_HTTP_FLAGS_NO_EXACT_MATCH) {
;;;594    		/* The contents match as much as the API length, so this is good
;;;595    		 * enough for us.
;;;596    		 */
;;;597    		return 0;
;;;598    	}
;;;599    
;;;600    	/* We come here only if we need an exact match. */
;;;601    
;;;602    	/* '?' terminates the pathname, so this is an exact match. There may be
;;;603    	 * some additional parameters that follow the '?', but that isn't a part
;;;604    	 * of the path name.
;;;605    	 */
;;;606    	if (*c1 == '?')
;;;607    		return 0;
;;;608    
;;;609    	/* Skip over any trailing forward slashes */
;;;610    	while (*c1 && (*c1 == '/'))
;;;611    			c1++;
;;;612    
;;;613    	if (*c1)
;;;614    		return -1;
;;;615    	else
;;;616    		return 0;
;;;617    }
00001a  bd70              POP      {r4-r6,pc}
                  |L16.28|
00001c  1c49              ADDS     r1,r1,#1              ;589
00001e  1c52              ADDS     r2,r2,#1              ;590
                  |L16.32|
000020  7810              LDRB     r0,[r2,#0]            ;586
000022  2800              CMP      r0,#0                 ;586
000024  d1f3              BNE      |L16.14|
000026  f0050001          AND      r0,r5,#1              ;593
00002a  b108              CBZ      r0,|L16.48|
00002c  2000              MOVS     r0,#0                 ;597
00002e  e7f4              B        |L16.26|
                  |L16.48|
000030  7808              LDRB     r0,[r1,#0]            ;606
000032  283f              CMP      r0,#0x3f              ;606
000034  d101              BNE      |L16.58|
000036  2000              MOVS     r0,#0                 ;607
000038  e7ef              B        |L16.26|
                  |L16.58|
00003a  e000              B        |L16.62|
                  |L16.60|
00003c  1c49              ADDS     r1,r1,#1              ;611
                  |L16.62|
00003e  7808              LDRB     r0,[r1,#0]            ;610
000040  b110              CBZ      r0,|L16.72|
000042  7808              LDRB     r0,[r1,#0]            ;610
000044  282f              CMP      r0,#0x2f              ;610
000046  d0f9              BEQ      |L16.60|
                  |L16.72|
000048  7808              LDRB     r0,[r1,#0]            ;613
00004a  b110              CBZ      r0,|L16.82|
00004c  f04f30ff          MOV      r0,#0xffffffff        ;614
000050  e7e3              B        |L16.26|
                  |L16.82|
000052  2000              MOVS     r0,#0                 ;616
000054  e7e1              B        |L16.26|
;;;618    
                          ENDP


                          AREA ||i.httpd_wsgi||, CODE, READONLY, ALIGN=2

                  httpd_wsgi PROC
;;;620    /* Check if there are any matching WSGI calls, and if so, execute them. */
;;;621    int httpd_wsgi(httpd_request_t *req_p)
000000  e92d4ffe          PUSH     {r1-r11,lr}
;;;622    {
000004  4680              MOV      r8,r0
;;;623    	struct httpd_wsgi_call *f;
;;;624    	int err = -WM_E_HTTPD_NO_HANDLER;
000006  f06f0a08          MVN      r10,#8
;;;625    	int index, ret = 0;
00000a  f04f0b00          MOV      r11,#0
;;;626    	int match_index = -1, cur_char_match = 0;
00000e  f04f34ff          MOV      r4,#0xffffffff
000012  2000              MOVS     r0,#0
000014  9002              STR      r0,[sp,#8]
;;;627    	bool found;
;;;628    
;;;629    	char *ptr, *request = httpd_skip_absolute_http_path(req_p->filename);
000016  f1080004          ADD      r0,r8,#4
00001a  f7fffffe          BL       httpd_skip_absolute_http_path
00001e  4681              MOV      r9,r0
;;;630    
;;;631    	httpd_d("httpd_wsgi: looking for %s", request);
;;;632            
;;;633    	/* IMP: fixme: Need to check for ? at the end or any forward slashes /
;;;634    	 * httpd_validate URI? */
;;;635    	for (index = 0; index < MAX_WSGI_HANDLERS; index++) {
000020  2700              MOVS     r7,#0
000022  e03c              B        |L17.158|
                  |L17.36|
;;;636    		f = calls[index];
000024  4851              LDR      r0,|L17.364|
000026  f8505027          LDR      r5,[r0,r7,LSL #2]
;;;637    		if (f == NULL)
00002a  b905              CBNZ     r5,|L17.46|
;;;638    			continue;
00002c  e036              B        |L17.156|
                  |L17.46|
;;;639    		if (f->http_flags & APP_HTTP_FLAGS_NO_EXACT_MATCH) {
00002e  7a28              LDRB     r0,[r5,#8]
000030  f0000001          AND      r0,r0,#1
000034  b158              CBZ      r0,|L17.78|
;;;640    			ret = get_matching_chars(request,
000036  4648              MOV      r0,r9
000038  6829              LDR      r1,[r5,#0]
00003a  f7fffffe          BL       get_matching_chars
00003e  4683              MOV      r11,r0
;;;641    						f->uri);
;;;642    			if (ret > cur_char_match) {
000040  9802              LDR      r0,[sp,#8]
000042  4583              CMP      r11,r0
000044  dd29              BLE      |L17.154|
;;;643    				cur_char_match = ret;
000046  f8cdb008          STR      r11,[sp,#8]
;;;644    				match_index = index;
00004a  463c              MOV      r4,r7
00004c  e025              B        |L17.154|
                  |L17.78|
;;;645    			}
;;;646    		} else {
;;;647    			if (!strncmp(request, f->uri, strlen(f->uri))) {
00004e  6828              LDR      r0,[r5,#0]
000050  f7fffffe          BL       strlen
000054  9000              STR      r0,[sp,#0]
000056  4602              MOV      r2,r0
000058  4648              MOV      r0,r9
00005a  6829              LDR      r1,[r5,#0]
00005c  f7fffffe          BL       strncmp
000060  b9d8              CBNZ     r0,|L17.154|
;;;648    				found = 0;
000062  2000              MOVS     r0,#0
000064  9001              STR      r0,[sp,#4]
;;;649    				ptr = request;
000066  464e              MOV      r6,r9
;;;650    				ptr += strlen(f->uri);
000068  6828              LDR      r0,[r5,#0]
00006a  f7fffffe          BL       strlen
00006e  4406              ADD      r6,r6,r0
;;;651    				/* '?' terminates a filename */
;;;652    				if (*ptr == '?')
000070  7830              LDRB     r0,[r6,#0]
000072  283f              CMP      r0,#0x3f
000074  d102              BNE      |L17.124|
;;;653    					found = 1;
000076  2001              MOVS     r0,#1
000078  9001              STR      r0,[sp,#4]
00007a  e00a              B        |L17.146|
                  |L17.124|
;;;654    				else {
;;;655    					/* Check for any number of
;;;656    					 * forward slashes */
;;;657    					while (*ptr && (*ptr == '/')) {
00007c  e000              B        |L17.128|
                  |L17.126|
;;;658    						ptr++;
00007e  1c76              ADDS     r6,r6,#1
                  |L17.128|
000080  7830              LDRB     r0,[r6,#0]            ;657
000082  b110              CBZ      r0,|L17.138|
000084  7830              LDRB     r0,[r6,#0]            ;657
000086  282f              CMP      r0,#0x2f              ;657
000088  d0f9              BEQ      |L17.126|
                  |L17.138|
;;;659    					}
;;;660    					if (!*ptr)
00008a  7830              LDRB     r0,[r6,#0]
00008c  b908              CBNZ     r0,|L17.146|
;;;661    						found = 1;
00008e  2001              MOVS     r0,#1
000090  9001              STR      r0,[sp,#4]
                  |L17.146|
;;;662    				}
;;;663    				if (found) {
000092  9801              LDR      r0,[sp,#4]
000094  b108              CBZ      r0,|L17.154|
;;;664    					httpd_d("Anchored pattern match: %s",
;;;665    						f->uri);
;;;666    					match_index = index;
000096  463c              MOV      r4,r7
;;;667    					/* Break if there is an exact match */
;;;668    					break;
000098  e003              B        |L17.162|
                  |L17.154|
00009a  bf00              NOP                            ;638
                  |L17.156|
00009c  1c7f              ADDS     r7,r7,#1              ;635
                  |L17.158|
00009e  2f20              CMP      r7,#0x20              ;635
0000a0  dbc0              BLT      |L17.36|
                  |L17.162|
0000a2  bf00              NOP      
;;;669    				}
;;;670    			}
;;;671    		}
;;;672    	}
;;;673    	if (match_index == -1)
0000a4  1c60              ADDS     r0,r4,#1
0000a6  b910              CBNZ     r0,|L17.174|
;;;674    		return err;
0000a8  4650              MOV      r0,r10
                  |L17.170|
;;;675    
;;;676    	/* Match found. So map the wsgi to this request */
;;;677    	req_p->wsgi = calls[match_index];
;;;678    	switch (req_p->type) {
;;;679    	case HTTPD_REQ_TYPE_HEAD:
;;;680    	case HTTPD_REQ_TYPE_GET:
;;;681    		if (calls[match_index]->get_handler)
;;;682    			err = calls[match_index]->get_handler(req_p);
;;;683    		else
;;;684    			return err;
;;;685    		break;
;;;686    	case HTTPD_REQ_TYPE_POST:
;;;687    		if (calls[match_index]->set_handler)
;;;688    			err = calls[match_index]->set_handler(req_p);
;;;689    		else
;;;690    			return err;
;;;691    		break;
;;;692    	case HTTPD_REQ_TYPE_PUT:
;;;693    		if (calls[match_index]->put_handler)
;;;694    			err = calls[match_index]->put_handler(req_p);
;;;695    		else
;;;696    			return err;
;;;697    		break;
;;;698    	case HTTPD_REQ_TYPE_DELETE:
;;;699    		if (calls[match_index]->delete_handler)
;;;700    			err = calls[match_index]->delete_handler(req_p);
;;;701    		else
;;;702    			return err;
;;;703    		break;
;;;704    	default:
;;;705    		return err;
;;;706    	}
;;;707    
;;;708    	if (err == kNoErr)
;;;709    		return HTTPD_DONE;
;;;710    	else
;;;711    		return err;
;;;712    
;;;713    }
0000aa  e8bd8ffe          POP      {r1-r11,pc}
                  |L17.174|
0000ae  482f              LDR      r0,|L17.364|
0000b0  f8500024          LDR      r0,[r0,r4,LSL #2]     ;677
0000b4  f8c80058          STR      r0,[r8,#0x58]         ;677
0000b8  f8d80000          LDR      r0,[r8,#0]            ;678
0000bc  2804              CMP      r0,#4                 ;678
0000be  d02a              BEQ      |L17.278|
0000c0  dc04              BGT      |L17.204|
0000c2  2801              CMP      r0,#1                 ;678
0000c4  d017              BEQ      |L17.246|
0000c6  2802              CMP      r0,#2                 ;678
0000c8  d145              BNE      |L17.342|
0000ca  e004              B        |L17.214|
                  |L17.204|
0000cc  2808              CMP      r0,#8                 ;678
0000ce  d032              BEQ      |L17.310|
0000d0  2810              CMP      r0,#0x10              ;678
0000d2  d140              BNE      |L17.342|
0000d4  bf00              NOP                            ;680
                  |L17.214|
0000d6  4825              LDR      r0,|L17.364|
0000d8  f8500024          LDR      r0,[r0,r4,LSL #2]     ;681
0000dc  68c0              LDR      r0,[r0,#0xc]          ;681
0000de  b138              CBZ      r0,|L17.240|
0000e0  4822              LDR      r0,|L17.364|
0000e2  f8500024          LDR      r0,[r0,r4,LSL #2]     ;682
0000e6  68c1              LDR      r1,[r0,#0xc]          ;682
0000e8  4640              MOV      r0,r8                 ;682
0000ea  4788              BLX      r1                    ;682
0000ec  4682              MOV      r10,r0                ;682
0000ee  e001              B        |L17.244|
                  |L17.240|
0000f0  4650              MOV      r0,r10                ;684
0000f2  e7da              B        |L17.170|
                  |L17.244|
0000f4  e031              B        |L17.346|
                  |L17.246|
0000f6  481d              LDR      r0,|L17.364|
0000f8  f8500024          LDR      r0,[r0,r4,LSL #2]     ;687
0000fc  6900              LDR      r0,[r0,#0x10]         ;687
0000fe  b138              CBZ      r0,|L17.272|
000100  481a              LDR      r0,|L17.364|
000102  f8500024          LDR      r0,[r0,r4,LSL #2]     ;688
000106  6901              LDR      r1,[r0,#0x10]         ;688
000108  4640              MOV      r0,r8                 ;688
00010a  4788              BLX      r1                    ;688
00010c  4682              MOV      r10,r0                ;688
00010e  e001              B        |L17.276|
                  |L17.272|
000110  4650              MOV      r0,r10                ;690
000112  e7ca              B        |L17.170|
                  |L17.276|
000114  e021              B        |L17.346|
                  |L17.278|
000116  4815              LDR      r0,|L17.364|
000118  f8500024          LDR      r0,[r0,r4,LSL #2]     ;693
00011c  6940              LDR      r0,[r0,#0x14]         ;693
00011e  b138              CBZ      r0,|L17.304|
000120  4812              LDR      r0,|L17.364|
000122  f8500024          LDR      r0,[r0,r4,LSL #2]     ;694
000126  6941              LDR      r1,[r0,#0x14]         ;694
000128  4640              MOV      r0,r8                 ;694
00012a  4788              BLX      r1                    ;694
00012c  4682              MOV      r10,r0                ;694
00012e  e001              B        |L17.308|
                  |L17.304|
000130  4650              MOV      r0,r10                ;696
000132  e7ba              B        |L17.170|
                  |L17.308|
000134  e011              B        |L17.346|
                  |L17.310|
000136  480d              LDR      r0,|L17.364|
000138  f8500024          LDR      r0,[r0,r4,LSL #2]     ;699
00013c  6980              LDR      r0,[r0,#0x18]         ;699
00013e  b138              CBZ      r0,|L17.336|
000140  480a              LDR      r0,|L17.364|
000142  f8500024          LDR      r0,[r0,r4,LSL #2]     ;700
000146  6981              LDR      r1,[r0,#0x18]         ;700
000148  4640              MOV      r0,r8                 ;700
00014a  4788              BLX      r1                    ;700
00014c  4682              MOV      r10,r0                ;700
00014e  e001              B        |L17.340|
                  |L17.336|
000150  4650              MOV      r0,r10                ;702
000152  e7aa              B        |L17.170|
                  |L17.340|
000154  e001              B        |L17.346|
                  |L17.342|
000156  4650              MOV      r0,r10                ;705
000158  e7a7              B        |L17.170|
                  |L17.346|
00015a  bf00              NOP                            ;685
00015c  f1ba0f00          CMP      r10,#0                ;708
000160  d101              BNE      |L17.358|
000162  2001              MOVS     r0,#1                 ;709
000164  e7a1              B        |L17.170|
                  |L17.358|
000166  4650              MOV      r0,r10                ;711
000168  e79f              B        |L17.170|
;;;714    
                          ENDP

00016a  0000              DCW      0x0000
                  |L17.364|
                          DCD      calls

                          AREA ||i.httpd_wsgi_init||, CODE, READONLY, ALIGN=2

                  httpd_wsgi_init PROC
;;;715    /* Initialise the WSGI handler data structures */
;;;716    int httpd_wsgi_init(void)
000000  b510              PUSH     {r4,lr}
;;;717    {
;;;718    	memset(calls, 0, sizeof(calls));
000002  2180              MOVS     r1,#0x80
000004  4802              LDR      r0,|L18.16|
000006  f7fffffe          BL       __aeabi_memclr4
;;;719    
;;;720    	return kNoErr;
00000a  2000              MOVS     r0,#0
;;;721    }
00000c  bd10              POP      {r4,pc}
                          ENDP

00000e  0000              DCW      0x0000
                  |L18.16|
                          DCD      calls

                          AREA ||.bss||, DATA, NOINIT, ALIGN=2

                  calls
                          %        128
                  http_response
                          %        256

;*** Start embedded assembler ***

#line 1 "..\\..\\..\\..\\libraries\\daemons\\http_server\\httpd_wsgi.c"
	AREA ||.rev16_text||, CODE
	THUMB
	EXPORT |__asm___12_httpd_wsgi_c_5231a476____REV16|
#line 114 "..\\..\\..\\..\\Platform\\Cortex-M4\\CMSIS\\core_cmInstr.h"
|__asm___12_httpd_wsgi_c_5231a476____REV16| PROC
#line 115

 rev16 r0, r0
 bx lr
	ENDP
	AREA ||.revsh_text||, CODE
	THUMB
	EXPORT |__asm___12_httpd_wsgi_c_5231a476____REVSH|
#line 128
|__asm___12_httpd_wsgi_c_5231a476____REVSH| PROC
#line 129

 revsh r0, r0
 bx lr
	ENDP

;*** End   embedded assembler ***
