xnbox / DeepfakeHTTP

DeepfakeHTTP is a web server that uses HTTP dumps as a source for responses.
MIT License
513 stars 46 forks source link

Custom separator #21

Open mjablecnik opened 3 years ago

mjablecnik commented 3 years ago

Hello, I want to use my own custom separator instead of '.' but when I add '#---' so it doesn't work. Do you know why? I have there '#' for make as comment it..

Here is example of my file:

#---

POST /dapi/v1/inventory/item/EAN123/save HTTP/1.1

{"items":["SN123","SN124","SN125","SN126"]}

HTTP/1.1 200 OK

#---

GET /dapi/v1/inventory/item/SN123/check HTTP/1.1

HTTP/1.1 200 OK
Content-Type: application/json

{
  "in_stock": true
}

#---

GET /dapi/v1/inventory/item/SN123/location HTTP/1.1

HTTP/1.1 200 OK
Content-Type: application/json

{
  "location": {
    "code": "1-2-3A",
    "name": "L123A"
  }
}

#---

My version is: 1.0.14

xnbox commented 3 years ago

Hi, '.'-separator separates the body of the request/response from everything else (we have to somehow determine where the body ends). If there is no comment '.'-separator does not have to be used. If the comment character '#' is inside the body, it will not be treated as a comment, but as part of the body. If the exact length of the body is not necessary (for JSON, for example) you don't have to use a dot. But perhaps I should consider adding an option to change the default delimiter.