Open CaptainQuirk opened 6 months ago
curl -i https://medv.io | fx -rs | fx
Hi,
Thank you for your quick response !
There may have been a misunderstanding because the command you proposed returns a json array of headers, which is not what I had in mind
I was wondering if the current fx viewport could contain :
Something like the following :
HTTP/1.1 200 OK
Content-Length: 11910
{
"result": { }
}
I see. I nice idea but I'm not sure how to be able to detect those kinds of headers. It should be integrated into our json parser which will be tricky.
I'm not aware of the component you use for the presentation layer, nor of the global architecture of fx, but maybe it means that the viewport has to be composed of two different parts, one dedicated to json with its attached parser (jq ?) and an optional one for headers ?
Problem is not with displaying the headers. Problem is with parsing them. How to distinguish them from JSON? Or invalid JSON?
Wouldn't a regular expression help to determine that the given data is the combination of http headers and a body separated by a null line, like it's stipulated in rfc1945 section-4.1 ?
In any case, if the regular expression is not the way to go, wouldn't an additionnal flag do the trick ?
What about an --http
flag that instructs fx that the given data is indeed http ?
I guess we can add a custom parser which checks if a first line is from curl, and starts parsing headers.
HTTP/1.1 200 OK
Would you like to try to implement such a feature? Note parser should be implemented in both Go parser and JS parser: https://github.com/antonmedv/fx/blob/19520743f7e7b6eadc630cf96d3268c83027e5b9/json.go#L20 https://github.com/antonmedv/fx/blob/19520743f7e7b6eadc630cf96d3268c83027e5b9/npm/index.js#L272
Hi !
I have no notion of Go whatsoever unfortunately
Hi,
Thanks for fx ! It's a great tool to explore json without leaving the terminal.
I guess this is a bit out of scope (and possibly complicated to achieve) but I think it would be great to be able to pipe the result of a curl request with the
-i
flag to fx and have the headers displayed at the top of the viewport.Thanks for your time !