Ejemplo n.º 1
0
func buildResp(html string) *http.Response {
	blk.Lock()
	defer blk.Unlock()
	resp, err := http.DupResp(respOK)
	if err != nil {
		panic("v")
	}
	resp.Body = http.StringToBody(html)
	resp.ContentLength = int64(len(html))
	return resp
}
Ejemplo n.º 2
0
func buildResp(html string) *http.Response {
	resp := &http.Response{
		Status:        "OK",
		StatusCode:    200,
		Proto:         "HTTP/1.1",
		ProtoMajor:    1,
		ProtoMinor:    1,
		RequestMethod: "GET",
		Close:         false,
	}
	resp.Body = http.StringToBody(html)
	resp.ContentLength = int64(len(html))
	return resp
}
Ejemplo n.º 3
0
func newRespNotFound() *http.Response {
	htmlErrNotFound := "<html>" +
		"<head><title>404 Resource Not Found</title></head>\n" +
		"<body bgcolor=\"white\">\n" +
		"<center><h1>404 Resource Not Found</h1></center>\n" +
		"<hr><center>Tonika Web Server</center>\n" +
		"</body></html>"
	respErrNotFound := &http.Response{
		Status:        "Resource Not Found",
		StatusCode:    404,
		Proto:         "HTTP/1.1",
		ProtoMajor:    1,
		ProtoMinor:    1,
		RequestMethod: "GET",
		Body:          http.StringToBody(htmlErrNotFound),
		ContentLength: int64(len(htmlErrNotFound)),
		Close:         false,
	}
	return respErrNotFound
}
Ejemplo n.º 4
0
func newRespServiceUnavailable() *http.Response {
	htmlErrServiceUnavailable := "<html>" +
		"<head><title>503 Service Unavailable</title></head>\n" +
		"<body bgcolor=\"white\">\n" +
		"<center><h1>503 Service Unavailable</h1></center>\n" +
		"<hr><center>Tonika Web Server</center>\n" +
		"</body></html>"
	respErrServiceUnavailable := &http.Response{
		Status:        "Service Unavailable",
		StatusCode:    503,
		Proto:         "HTTP/1.1",
		ProtoMajor:    1,
		ProtoMinor:    1,
		RequestMethod: "GET",
		Body:          http.StringToBody(htmlErrServiceUnavailable),
		ContentLength: int64(len(htmlErrServiceUnavailable)),
		Close:         false,
	}
	return respErrServiceUnavailable
}
Ejemplo n.º 5
0
var (
	// Service unavailable
	htmlErrServiceUnavailable = "<html>" +
		"<head><title>503 Service Unavailable</title></head>\n" +
		"<body bgcolor=\"white\">\n" +
		"<center><h1>503 Service Unavailable</h1></center>\n" +
		"<hr><center>" + sys.Name + " Front End</center>\n" +
		"</body></html>"
	respErrServiceUnavailable = &http.Response{
		Status:        "Service Unavailable",
		StatusCode:    503,
		Proto:         "HTTP/1.1",
		ProtoMajor:    1,
		ProtoMinor:    1,
		RequestMethod: "GET",
		Body:          http.StringToBody(htmlErrServiceUnavailable),
		ContentLength: int64(len(htmlErrServiceUnavailable)),
		Close:         false,
	}
	// Not found
	htmlErrNotFound = "<html>" +
		"<head><title>404 Resource Not Found</title></head>\n" +
		"<body bgcolor=\"white\">\n" +
		"<center><h1>404 Resource Not Found</h1></center>\n" +
		"<hr><center>" + sys.Name + " Front End</center>\n" +
		"</body></html>"
	respErrNotFound = &http.Response{
		Status:        "Resource Not Found",
		StatusCode:    404,
		Proto:         "HTTP/1.1",
		ProtoMajor:    1,