Having a simple GO WebServer which accepts an image as part of POST request.
Code snippet - Request is mapped to this function
func UploadFile(w http.ResponseWriter, r *http.Request, p httprouter.Params) {
successResponse := models.HTTPResponse {
FileURL:"http://testing.com",
}
WrapResponse(w, successResponse, http.StatusOK)
}
Response writer function
func WrapResponse(writer http.ResponseWriter, content interface{}, status int) {
writer.Header().Set("Content-Type", "application/json")
writer.WriteHeader(status)
// Content is a struct Response { fileURL string }
responseJson, err := json.Marshal(content)
CheckError(err, "Error wrapping response")
writer.Write(responseJson)
}
func CheckError(err error, msg string) {
if err != nil {
panic(fmt.Sprintf("%s : %s", msg, err))
}
}
When i hit the URL using cURL as below the response is 200 OK (as expected)
curl -X POST -d@ "Screen Shot 2015-11-15 at 6.09.58 pm.png" http://localhost:8000/image/agent123/property --header "Content-Type:image/png" --header "X-User-Agent:agent-php" response -->{"fileURL":"http://testing.com"}%
Entire cURL request & response
But when i try the same from DHC rest client, have also tried with advanced rest client getting no response.
Edit 1: Request does reach the server when fired from rest clients