TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Making http clients for use with netcat-like programs, part 2 of 2

1 pointsby textmodealmost 7 years ago
part 2 of 2<p><pre><code> # make new http client (yy025) # hh2 is an #include in 025.l below yy018 &lt; hh1 &gt; hh2; flex -8iCrfa 025.l; # cpp -P 025.l|less; cc -static -o yy025 lex.yy.c; </code></pre> save as &quot;025.l&quot;<p><pre><code> #define httpMethod &quot;GET&quot; #define httpVersion &quot;1.1&quot; #define Host &quot;&quot; #define jmp BEGIN #define se setenv #define g getenv #define p(x,y) fprintf(stdout,x,y) int count,path,ka; int httpheaders() { se(&quot;httpMethod&quot;,httpMethod,0);p(&quot;%s &quot;,g(&quot;httpMethod&quot;)); p(&quot;%s HTTP&#x2F;&quot;,g(&quot;Path&quot;)); se(&quot;httpVersion&quot;,httpVersion,0);p(&quot;%s\r\n&quot;,g(&quot;httpVersion&quot;)); #include &quot;hh2&quot; fputs(&quot;\r\n&quot;,stdout); } int keepaliveclose() { se(&quot;Connection&quot;,&quot;close&quot;,1); } %s xa xb xc xa &quot;http:&#x2F;&#x2F;&quot;|&quot;https:&#x2F;&#x2F;&quot; xb [-A-Za-z0-9.:]* xc [^#&#x27;|&lt;&gt; \r\n]* %% ^{xa} count++;se(&quot;Scheme&quot;,yytext,0);jmp xa; &lt;xa&gt;{xb} se(&quot;Host&quot;,yytext,1);if(!g(&quot;Host&quot;))se(&quot;Host&quot;,Host,0);jmp xb; &lt;xb&gt;\n path=0;se(&quot;Path&quot;,&quot;&#x2F;&quot;,0);httpheaders();jmp 0; &lt;xb&gt;{xc} path=1;se(&quot;Path&quot;,yytext,1);httpheaders();jmp 0; .|\n %% int main() { yylex(); if(!g(&quot;nokac&quot;))if(count&gt;1){keepaliveclose();httpheaders();} } int yywrap() { &#x2F;* dprintf(6,&quot;%s&quot;,g(&quot;Host&quot;)); *&#x2F; }</code></pre>

no comments

no comments