[fractal] Add Content-Length: 0 header to JSON queries if the length is in fact zero



commit 0748badf1a5ca09fc9acf8bdace4a5c98fa57caa
Author: Scott Sweeny <scott ssweeny net>
Date:   Sat Apr 27 12:02:45 2019 -0400

    Add Content-Length: 0 header to JSON queries if the length is in fact zero
    
    When using lighttpd as a reverse proxy empty POSTs get rejected by the
    server if they don't have Content-Length set to zero, so some calls like
    marking a room as read fail to make it to the homeserver.
    
    fixes: GNOME/fractal#475

 fractal-matrix-api/src/util.rs | 3 +++
 1 file changed, 3 insertions(+)
---
diff --git a/fractal-matrix-api/src/util.rs b/fractal-matrix-api/src/util.rs
index d1f15593..09985f07 100644
--- a/fractal-matrix-api/src/util.rs
+++ b/fractal-matrix-api/src/util.rs
@@ -23,6 +23,7 @@ use crate::error::Error;
 use crate::types::Message;
 use crate::types::RoomEventFilter;
 
+use reqwest::header::CONTENT_LENGTH;
 use reqwest::header::CONTENT_TYPE;
 
 use crate::globals;
@@ -357,6 +358,8 @@ pub fn json_q(method: &str, url: &Url, attrs: &JsonValue) -> Result<JsonValue, E
 
     if !attrs.is_null() {
         conn = conn.json(attrs);
+    } else {
+        conn = conn.header(CONTENT_LENGTH, 0);
     }
 
     let mut res = conn.send()?;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]