@@ -37,14 +37,16 @@ const (
3737 BufLen = 4096
3838 SerializePlain = 0
3939 SerializeJson = 1
40- FSStatusReply = `UP %d years, %d days, %d hours, %d minutes, %d seconds, %d milliseconds, %d microseconds
40+ FSApiResponseHeader = `Content-Length: %d
41+ Content-Type: api/response`
42+ FSStatusReply = `UP %d years, %d days, %d hours, %d minutes, %d seconds, %d milliseconds, %d microseconds
4143FreeSWITCH (Version 1.8.7 git 6047ebd 2019-07-02 20:06:09Z 64bit) is ready
42440 session(s) since startup
43450 session(s) - peak 0, last 5min 0
44460 session(s) per Sec out of max 30, peak 0, last 5min 0
45471000 session(s) max
4648min idle cpu 0.00/99.73
47- Current Stack Size/Max 240K/8192K`
49+ Current Stack Size/Max 240K/8192K\n\n `
4850)
4951
5052type Worker struct {
@@ -175,11 +177,19 @@ func (fs *Worker) processCommand(s string) {
175177 if args [0 ] == "status" {
176178 Y , M , D , H , m , sec := diff (time .Now (), fs .startTime )
177179 reply = fmt .Sprintf (FSStatusReply , Y , M , D , H , m , sec , 0 )
180+ s := fmt .Sprintf (FSApiResponseHeader , len (reply )+ 1 )
181+ if _ , err := fs .conn .Write ([]byte (s )); err != nil {
182+ fs .stop = true
183+ return
184+ }
185+ if _ , err := fs .conn .Write ([]byte (fmt .Sprintf ("%s\n " , reply ))); err != nil {
186+ fs .stop = true
187+ return
188+ }
178189 } else {
179- reply = FsErrCommandNotFound
180- }
181- if _ , err := fs .conn .Write ([]byte (reply )); err != nil {
182- fs .stop = true
190+ if _ , err := fs .conn .Write ([]byte (FsErrCommandNotFound )); err != nil {
191+ fs .stop = true
192+ }
183193 }
184194 default :
185195 if _ , err := fs .conn .Write ([]byte (FsErrCommandNotFound )); err != nil {
0 commit comments