Thanks for pointing that out.
On the other hand (being pedantic), maybe the second argument "HEAD",
being of type char [5], and thus passed as type (char *) to
fossil_strcmp(), should be casted to (const char*), right?

> -  if (fossil_strcmp((char*)P("REQUEST_METHOD"),"HEAD")!=0)

> +  if (fossil_strcmp(P("REQUEST_METHOD"),(const char*)"HEAD")!=0)

BR,
Johan




Index: src/cgi.c
==================================================================
--- src/cgi.c
+++ src/cgi.c
@@ -382,16 +382,22 @@
     fprintf(g.httpOut, "Content-Length: %d\r\n", total_size);
   }else{
     total_size = 0;
   }
   fprintf(g.httpOut, "\r\n");
-  if( total_size>0 && iReplyStatus != 304 ){
-    int i, size;
-    for(i=0; i<2; i++){
-      size = blob_size(&cgiContent[i]);
-      if( size>0 ){
-        fwrite(blob_buffer(&cgiContent[i]), 1, size, g.httpOut);
+  /* RFC7231, section 4.3.2:
+     The HEAD method is identical to GET except that the server MUST
NOT send a message body in the response
+     (i.e., the response terminates at the end of the header section). */
+  if (fossil_strcmp(P("REQUEST_METHOD"),(const char *)"HEAD")!=0)
+  {
+    if( total_size>0 && iReplyStatus != 304 ){
+      int i, size;
+      for(i=0; i<2; i++){
+        size = blob_size(&cgiContent[i]);
+        if( size>0 ){
+          fwrite(blob_buffer(&cgiContent[i]), 1, size, g.httpOut);
+        }
       }
     }
   }
   fflush(g.httpOut);
   CGIDEBUG(("DONE\n"));


On Tue, Jul 4, 2017 at 2:35 PM, Stephan Beal <sgb...@googlemail.com> wrote:
> On Tue, Jul 4, 2017 at 8:39 AM, Johan Kuuse <jo...@kuu.se> wrote:
>
>> +  if (fossil_strcmp((char*)P("REQUEST_METHOD"),"HEAD")!=0)
>>
>
> One minor nitpick:
>
> fossil_strcmp() takes a const char *, which is the return type of P(), so
> no cast is needed there.
>
> --
> ----- stephan beal
> http://wanderinghorse.net/home/stephan/
> "Freedom is sloppy. But since tyranny's the only guaranteed byproduct of
> those who insist on a perfect world, freedom will have to do." -- Bigby Wolf
> _______________________________________________
> fossil-dev mailing list
> fossil-dev@mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/fossil-dev
_______________________________________________
fossil-dev mailing list
fossil-dev@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/fossil-dev

Reply via email to