You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by "jiahuili430 (via GitHub)" <gi...@apache.org> on 2025/09/17 17:23:17 UTC

[PR] Replace `gen_server:format_status/2` to `format_status/1` [couchdb-ibrowse]

jiahuili430 opened a new pull request, #8:
URL: https://github.com/apache/couchdb-ibrowse/pull/8

   Fix the following warnings:
   
   ```log
   [2025-09-17T13:01:35.309Z] /home/jenkins/workspace/next-multibranch-pipeline_otp-27/src/ibrowse/src/ibrowse_http_client.erl:9:2: Warning: the callback gen_server:format_status(_,_) is deprecated; use format_status/1 instead
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@couchdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Replace `gen_server:format_status/2` with `format_status/1` [couchdb-ibrowse]

Posted by "nickva (via GitHub)" <gi...@apache.org>.
nickva commented on code in PR #8:
URL: https://github.com/apache/couchdb-ibrowse/pull/8#discussion_r2373247487


##########
src/ibrowse_http_client.erl:
##########
@@ -324,34 +324,55 @@ code_change(_OldVsn, State, _Extra) ->
 
 
 %%--------------------------------------------------------------------
-%% Function: format_status/2
+%% Function: format_status/1
 %% Purpose: Clean process state before logging
-%% Returns: key value list
+%% Returns: key value maps
 %%--------------------------------------------------------------------
-format_status(_Opt, [_PDict, State]) ->
-    #state{
-        reqs=Reqs,
-        reply_buffer=ReplyBuf,
-        recvd_headers=RCVDHeaders,
-        raw_headers=RawHeaders,
-        chunk_size_buffer=ChunkSizeBuf,
-        cur_req=Request
-    } = State,
-    ScrubbedReq = Request#request{url=url_strip_password(Request#request.url)},
-    Scrubbed = State#state{
-        reqs={queue_length, queue:len(Reqs)},
-        reply_buffer={byte_size, byte_size(ReplyBuf)},
-        recvd_headers=lists:map(fun({K, _V}) -> K end, RCVDHeaders),
-        raw_headers={byte_size, byte_size(RawHeaders)},
-        chunk_size_buffer={byte_size, byte_size(ChunkSizeBuf)},
-        cur_req=ScrubbedReq
-    },
-    [{data, [{"State",
-        lists:zip(
-            record_info(fields, state),
-            tl(tuple_to_list(Scrubbed))
-        )
-    }]}].
+format_status(Status) ->
+    maps:map(
+        fun
+            (state, State) ->
+                #state{
+                    reqs = Reqs,
+                    reply_buffer = ReplyBuf,
+                    recvd_headers = RCVDHeaders,
+                    raw_headers = RawHeaders,
+                    chunk_size_buffer = ChunkSizeBuf,
+                    cur_req = Request
+                } = State,
+                ScrubbedReq =
+                    case is_record(Request, request) of
+                        true ->
+                            Request#request{
+                                url = url_strip_password(Request#request.url)
+                            };
+                        false ->
+                            Request
+                    end,
+                RawHeadersSize =
+                    case is_bitstring(RawHeaders) of

Review Comment:
   Are raw headers bitstrings? I know this was there before but I wondering if this correct?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@couchdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Replace `gen_server:format_status/2` with `format_status/1` [couchdb-ibrowse]

Posted by "jiahuili430 (via GitHub)" <gi...@apache.org>.
jiahuili430 commented on code in PR #8:
URL: https://github.com/apache/couchdb-ibrowse/pull/8#discussion_r2373346588


##########
src/ibrowse_http_client.erl:
##########
@@ -324,34 +324,55 @@ code_change(_OldVsn, State, _Extra) ->
 
 
 %%--------------------------------------------------------------------
-%% Function: format_status/2
+%% Function: format_status/1
 %% Purpose: Clean process state before logging
-%% Returns: key value list
+%% Returns: key value maps
 %%--------------------------------------------------------------------
-format_status(_Opt, [_PDict, State]) ->
-    #state{
-        reqs=Reqs,
-        reply_buffer=ReplyBuf,
-        recvd_headers=RCVDHeaders,
-        raw_headers=RawHeaders,
-        chunk_size_buffer=ChunkSizeBuf,
-        cur_req=Request
-    } = State,
-    ScrubbedReq = Request#request{url=url_strip_password(Request#request.url)},
-    Scrubbed = State#state{
-        reqs={queue_length, queue:len(Reqs)},
-        reply_buffer={byte_size, byte_size(ReplyBuf)},
-        recvd_headers=lists:map(fun({K, _V}) -> K end, RCVDHeaders),
-        raw_headers={byte_size, byte_size(RawHeaders)},
-        chunk_size_buffer={byte_size, byte_size(ChunkSizeBuf)},
-        cur_req=ScrubbedReq
-    },
-    [{data, [{"State",
-        lists:zip(
-            record_info(fields, state),
-            tl(tuple_to_list(Scrubbed))
-        )
-    }]}].
+format_status(Status) ->
+    maps:map(
+        fun
+            (state, State) ->
+                #state{
+                    reqs = Reqs,
+                    reply_buffer = ReplyBuf,
+                    recvd_headers = RCVDHeaders,
+                    raw_headers = RawHeaders,
+                    chunk_size_buffer = ChunkSizeBuf,
+                    cur_req = Request
+                } = State,
+                ScrubbedReq =
+                    case is_record(Request, request) of
+                        true ->
+                            Request#request{
+                                url = url_strip_password(Request#request.url)
+                            };
+                        false ->
+                            Request
+                    end,
+                RawHeadersSize =
+                    case is_bitstring(RawHeaders) of

Review Comment:
   Not sure how to set `recvd_headers` and `raw_headers`.
   If I run CouchDB locally, `_replicate` the db to db2 continuously, and delete db2 with headers.
   It always `undefined`.
   
   Maybe I should use `is_binary()`?
   Because [`maybe_add_custom_headers/4`](https://github.com/apache/couchdb-ibrowse/blob/main/src/ibrowse_http_client.erl#L1954) is using `<<Raw_headers/binary, "\r\n", Custom_headers_bin/binary>>`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@couchdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Replace `gen_server:format_status/2` with `format_status/1` [couchdb-ibrowse]

Posted by "nickva (via GitHub)" <gi...@apache.org>.
nickva commented on code in PR #8:
URL: https://github.com/apache/couchdb-ibrowse/pull/8#discussion_r2376907568


##########
src/ibrowse_http_client.erl:
##########
@@ -324,34 +324,55 @@ code_change(_OldVsn, State, _Extra) ->
 
 
 %%--------------------------------------------------------------------
-%% Function: format_status/2
+%% Function: format_status/1
 %% Purpose: Clean process state before logging
-%% Returns: key value list
+%% Returns: key value maps
 %%--------------------------------------------------------------------
-format_status(_Opt, [_PDict, State]) ->
-    #state{
-        reqs=Reqs,
-        reply_buffer=ReplyBuf,
-        recvd_headers=RCVDHeaders,
-        raw_headers=RawHeaders,
-        chunk_size_buffer=ChunkSizeBuf,
-        cur_req=Request
-    } = State,
-    ScrubbedReq = Request#request{url=url_strip_password(Request#request.url)},
-    Scrubbed = State#state{
-        reqs={queue_length, queue:len(Reqs)},
-        reply_buffer={byte_size, byte_size(ReplyBuf)},
-        recvd_headers=lists:map(fun({K, _V}) -> K end, RCVDHeaders),
-        raw_headers={byte_size, byte_size(RawHeaders)},
-        chunk_size_buffer={byte_size, byte_size(ChunkSizeBuf)},
-        cur_req=ScrubbedReq
-    },
-    [{data, [{"State",
-        lists:zip(
-            record_info(fields, state),
-            tl(tuple_to_list(Scrubbed))
-        )
-    }]}].
+format_status(Status) ->
+    maps:map(
+        fun
+            (state, State) ->
+                #state{
+                    reqs = Reqs,
+                    reply_buffer = ReplyBuf,
+                    recvd_headers = RCVDHeaders,
+                    raw_headers = RawHeaders,
+                    chunk_size_buffer = ChunkSizeBuf,
+                    cur_req = Request
+                } = State,
+                ScrubbedReq =
+                    case is_record(Request, request) of
+                        true ->
+                            Request#request{
+                                url = url_strip_password(Request#request.url)
+                            };
+                        false ->
+                            Request
+                    end,
+                RawHeadersSize =
+                    case is_bitstring(RawHeaders) of

Review Comment:
   Yeah, let's just go with is_binary/0 that should work



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@couchdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Replace `gen_server:format_status/2` with `format_status/1` [couchdb-ibrowse]

Posted by "jiahuili430 (via GitHub)" <gi...@apache.org>.
jiahuili430 merged PR #8:
URL: https://github.com/apache/couchdb-ibrowse/pull/8


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@couchdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Replace `gen_server:format_status/2` with `format_status/1` [couchdb-ibrowse]

Posted by "jiahuili430 (via GitHub)" <gi...@apache.org>.
jiahuili430 commented on code in PR #8:
URL: https://github.com/apache/couchdb-ibrowse/pull/8#discussion_r2373346588


##########
src/ibrowse_http_client.erl:
##########
@@ -324,34 +324,55 @@ code_change(_OldVsn, State, _Extra) ->
 
 
 %%--------------------------------------------------------------------
-%% Function: format_status/2
+%% Function: format_status/1
 %% Purpose: Clean process state before logging
-%% Returns: key value list
+%% Returns: key value maps
 %%--------------------------------------------------------------------
-format_status(_Opt, [_PDict, State]) ->
-    #state{
-        reqs=Reqs,
-        reply_buffer=ReplyBuf,
-        recvd_headers=RCVDHeaders,
-        raw_headers=RawHeaders,
-        chunk_size_buffer=ChunkSizeBuf,
-        cur_req=Request
-    } = State,
-    ScrubbedReq = Request#request{url=url_strip_password(Request#request.url)},
-    Scrubbed = State#state{
-        reqs={queue_length, queue:len(Reqs)},
-        reply_buffer={byte_size, byte_size(ReplyBuf)},
-        recvd_headers=lists:map(fun({K, _V}) -> K end, RCVDHeaders),
-        raw_headers={byte_size, byte_size(RawHeaders)},
-        chunk_size_buffer={byte_size, byte_size(ChunkSizeBuf)},
-        cur_req=ScrubbedReq
-    },
-    [{data, [{"State",
-        lists:zip(
-            record_info(fields, state),
-            tl(tuple_to_list(Scrubbed))
-        )
-    }]}].
+format_status(Status) ->
+    maps:map(
+        fun
+            (state, State) ->
+                #state{
+                    reqs = Reqs,
+                    reply_buffer = ReplyBuf,
+                    recvd_headers = RCVDHeaders,
+                    raw_headers = RawHeaders,
+                    chunk_size_buffer = ChunkSizeBuf,
+                    cur_req = Request
+                } = State,
+                ScrubbedReq =
+                    case is_record(Request, request) of
+                        true ->
+                            Request#request{
+                                url = url_strip_password(Request#request.url)
+                            };
+                        false ->
+                            Request
+                    end,
+                RawHeadersSize =
+                    case is_bitstring(RawHeaders) of

Review Comment:
   Not sure how to set `recvd_headers` and `raw_headers`.
   If I run CouchDB locally, `_replicate` the db to db2 continuously, and delete db2 with headers.
   It always `undefined`.
   
   Maybe I should use `is_binary()`?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@couchdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org