diff options
author | Clayton <nrootconauto@gmail.com> | 2023-03-01 14:44:05 -0500 |
---|---|---|
committer | Clayton <nrootconauto@gmail.com> | 2023-03-01 14:44:05 -0500 |
commit | 46c4fb262396c002994c7dad1ec5ec9b7dd07a17 (patch) | |
tree | 3b7058aa5b86b45d5ca0413f76761668f1a6997a | |
parent | 7faa4e295525624b331a3b838b256a2d2d7bbca2 (diff) |
Doesn't respond incomplete requests
Cookies work across ngrok.
Fixed bug in backup.c regarding not closing a poopular DIV
-rw-r--r-- | T/Server/backup.HC | 2 | ||||
-rw-r--r-- | T/Server/http.HC | 27 | ||||
-rw-r--r-- | T/Wiki/HolyAsm.WIKI | 89 | ||||
-rw-r--r-- | T/Wiki/images/prolog.png | bin | 0 -> 191608 bytes |
4 files changed, 104 insertions, 14 deletions
diff --git a/T/Server/backup.HC b/T/Server/backup.HC index 563134f..8e42f20 100644 --- a/T/Server/backup.HC +++ b/T/Server/backup.HC @@ -284,8 +284,8 @@ U0 GenerateChangeLog(CDyadStream *s,U8 *name) { } else { WriteLn(s,NULL,"<A HREF=\""WIKI_BACKUP"%s/%s\">%D(%T)</A>",name,sorted[i]->name,date,time); } - WriteLn(s,NULL,"</DIV>"); fin: + WriteLn(s,NULL,"</DIV>"); Free(ftxt); Free(root_abs); } diff --git a/T/Server/http.HC b/T/Server/http.HC index df6baa9..a33c10b 100644 --- a/T/Server/http.HC +++ b/T/Server/http.HC @@ -292,14 +292,14 @@ U0 SendRequest(CDyadStream *s) { if(cookie=FramePtr(WIKI_SESSION_COOKIE)) { tmp="Credentials: include\x0d\n" "Mode: cors\x0d\n" - "Origin: http://localhost\x0d\n" +// "Origin: http://localhost\x0d\n" "Access-Control-Allow-Credentials: true\x0d\n" "Access-Control-Allow-Methods: POST, GET\x0d\n" - "Referrer-Policy: origin\x0d\n" - "Access-Control-Allow-Origin: http://localhost\x0d\n" + "Referrer-Policy: unsafe-url\x0d\n" +// "Access-Control-Allow-Origin: http://localhost\x0d\n" "Sec-Fetch-Mode: cors\x0d\n"; DyadWrite(s,tmp,StrLen(tmp)); - tmp=MStrPrint("Set-Cookie: " WIKI_SESSION_COOKIE "=%s; SameSite=None; Secure\x0d\n",cookie); + tmp=MStrPrint("Set-Cookie: " WIKI_SESSION_COOKIE "=%s; SameSite=Lax\x0d\n",cookie); Free(con->session_cookie); con->session_cookie=StrNew(cookie,con->hc); DyadWrite(s,tmp,StrLen(tmp)); @@ -402,6 +402,7 @@ U0 SReadLine(CDyadStream *s,U8 *data,I64 len,CUniqueToken *ut) { con->name=StrNew("",con->hc); con->post_data=HashTableNew(0x10,con->hc); found: + LBtr(&con_locked,0); buf=MAlloc(len+1,con->hc),buf2=MAlloc(len+1,con->hc); while(LBts(&con->lock,0)) Yield; @@ -423,7 +424,7 @@ found: con->method.u8[0]=HTTP_UNDEF; } else if(!StrNCmp(data,"Content-Length",StrLen("Content-Length"))) { data=SkipWhitespace(StrFirstOcc(data,":")+1); - con->fbuffer=MAlloc(Str2I64(data,con->hc)); + con->fbuffer=MAlloc(Str2I64(data),con->hc); con->content_len=Str2I64(data); } if(con->state.u8[0]==CON_S_BLANK_LINE&&len>2&&Bt(&con->state,CONf_URL_ENCODED)) { @@ -448,6 +449,7 @@ qloop: goto qloop; } Btr(&con->state,CONf_URL_ENCODED); + con->field_ptr=StrLen(odata); goto process; } else if(con->method==HTTP_POST&&con->state.u8[0]!=CON_S_BLANK_LINE&&StrOcc(data,':')) { t1=buf,t2=buf2; @@ -469,7 +471,6 @@ etag_loop: t1=buf; data=StrScan(data,"\"%s\"",&t1); if(ETagChanged(con->server,buf)){ - TOSPrint("ETAG_CHANGED:%s\n",buf); con->etag_changed=1; } if(*data==',') { @@ -526,7 +527,7 @@ cloop:; ) { if(con->field[0]) { hash=CAlloc(1+con->field_ptr+1+StrLen(con->name)+sizeof(CHashGeneric),con->hc); - hash->str=StrNew(con->field); + hash->str=StrNew(con->field,con->hc); if(con->field_length==-1) hash->user_data0=con->field_ptr-2; else @@ -561,7 +562,6 @@ loop: data++; goto loop; } - LBtr(&con_locked,0); LBtr(&con->lock,0); Free(buf),Free(buf2); return; @@ -587,16 +587,19 @@ en: //2 is \x0d\n if(len==2&&!Bt(&con->state,CONf_AWAIT_BOUNDARY)&&!(Bt(&con->state,CONf_URL_ENCODED)&&con->content_len)) goto process; - LBtr(&con_locked,0); LBtr(&con->lock,0); Free(buf),Free(buf2); return; process: Free(buf),Free(buf2); - LBtr(&con_locked,0); - LBtr(&con->lock,0); +//If we have content,make sure we recieved all the data + if((con->content_len&&con->content_len==con->field_ptr)||!con->content_len){ + Spawn(&ParseRequest,con,"Request",++spawn_at%mp_cnt); + LBtr(&con->lock,0); + } else { + LBtr(&con->lock,0); + } //ParseRequest will lock the con->lock - CTask *t=Spawn(&ParseRequest,con,"Request",++spawn_at%mp_cnt); } U0 CloseCallback(CDyadStream *s,CServer *ut) { //Killing the thread will fre the connection too diff --git a/T/Wiki/HolyAsm.WIKI b/T/Wiki/HolyAsm.WIKI index 0d41c30..8a16954 100644 --- a/T/Wiki/HolyAsm.WIKI +++ b/T/Wiki/HolyAsm.WIKI @@ -340,4 +340,91 @@ There is a special register called the +RFLAGS +register,but you can’t use it li "CmpTest(-1,0);\n"; CmpTest(-1,0); //-1 is the largest unsigned value "CmpTest(3,3);\n"; - CmpTest(3,3);
\ No newline at end of file + CmpTest(3,3); + +== Floating Points +In the old days,there was the *X87 FPU*. It was an add!-on processor that would allow your computer for work with decimals(instead of just integers). +It works with a stack of registers(Called ST0!-ST7).+ The registers are actually locations on the FPU stack,*ST0* is the bottom most item on the stack,and *ST7* is the farthest from the current stack item + +Many of the awesome FPU instructions end in _P_. This means the instruction *POP*s an item from the FPU stack ,which is very useful. In our below example,we use +FADDP+ to add ST0,ST1. We *POP* off one of our registers from the stack,and we store the result at *ST0* + + U0 SayF64(F64 f) { + "I Got %n\n",f; + } + asm { + _MAIN:: + PUSH RBP + MOV RBP,RSP + FLD U64 [@@a] + FLD U64 [@@b] + + //FPU Stack is + // ST1=>a + // ST0=>b + FADDP ST1,ST0 //This POPs ST0(b) and stores the result in ST0(a) + // ST0=>a+b + + SUB RSP,8 //Make room on (RSP)stack for a+b + + //This Pop's the FPU stack and stores the result + FSTP U64 [RSP] //STore+Pop the FPU stack + // FPU Stack is now empty + + CALL &SayF64 + + LEAVE + RET1 0 + @@a: + DU64 3.5; + @@b: + DU64 1.5123; + } + _extern _MAIN I64 Main(); + Main; + +== Mixing it up: Floating-Points with Integers +Mixing Integers and Floating!-Points is quite easy. We are given the *FILD* instruction for loading integers into the *X87 FPU*. If we want to store a floating point into an integer,we can use *FISTP*(which *POP*s for us) + + U0 SayF64(F64 f) { + "I Got %n\n",f; + } + I64 integer=0; + asm { + _MAIN:: + PUSH RBP + MOV RBP,RSP + FILD U64 SF_ARG1[RBP] //a + FILD U64 SF_ARG2[RBP] //b + + //FPU Stack is + // ST1=>a + // ST0=>b + FSUBP ST1,ST0 //This POPs ST0(b) and stores the result in ST0(a) + // ST0=>a-b + + SUB RSP,8 //Make room on stack for a+b + + //ST0=>a-b + + FLD ST0 //We "clone" ST0 onto the FPU stack + + //ST1=>a-b + //ST0=>a-b + + //Here we store ST0 into integer + FISTP [&integer] + + //ST0=>a-b + + //This Pop's the FPU stack and stores the result + FSTP U64 [RSP] //STore+Pop the FPU stack + // FPU Stack is now empty + + CALL &SayF64 + + LEAVE + RET1 2*8 + } + _extern _MAIN I64 Main(I64,I64); + Main(5,3); + + "integer is now %d\n",integer;
\ No newline at end of file diff --git a/T/Wiki/images/prolog.png b/T/Wiki/images/prolog.png Binary files differnew file mode 100644 index 0000000..6088f01 --- /dev/null +++ b/T/Wiki/images/prolog.png |