Put URL and body before headers
yDelouis opened this issue · 6 comments
Hi and thanks for the lib,
I'm using this lib in my project to have HTTP calls logged and be able to reproduce them and import them in Postman. It works great !
But it's quite hard to find the call we are looking for because every request log start with the same text :
curl -X GET -H "Authorization:Bearer <a very looonnngg token>" -H "<some more headers>: <some more headers values>" "https://<the url we are looking for>"
So we are still using a "standard" OkHttp logger to get the URL readable easily.
Would it be possible to change the order of arguments in the curl command to :
- the method
- the url
- the body
- headers
Ex :
curl -X GET "https://example.com/endpoint" -d "a body" -H "header1: foo" -H "header2: bar"
@yDelouis
That what works for me in most cases:
val headerIndex = message.indexOf("-H")
val urlIndex = message.indexOf("\"http")
val start = message.substring(0, headerIndex)
val headers = message.substring(headerIndex, urlIndex)
val url = message.substring(urlIndex)
Log.d("Curl", "$start$url $headers")
@disparate Thanks for your help, I didn't think of parsing the log string.
I'd still like that it is done by the lib. But in the meantime, I will add this !
+1
@disparate can you merge @flocsy's PR in? Is there a reason not to?