mirror of
https://github.com/clearlinux/uwsgi.git
synced 2026-09-06 13:41:28 +00:00
fixed go plugin
This commit is contained in:
+1
-1
@@ -420,7 +420,7 @@ void sanitize_args() {
|
||||
}
|
||||
}
|
||||
|
||||
const char *uwsgi_http_status_msg(char *status, size_t *len) {
|
||||
const char *uwsgi_http_status_msg(char *status, uint16_t *len) {
|
||||
struct http_status_codes *http_sc;
|
||||
for (http_sc = hsc; http_sc->message != NULL; http_sc++) {
|
||||
if (!strncmp(http_sc->key, status, 3)) {
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ int uwsgi_response_prepare_headers(struct wsgi_request *wsgi_req, char *status,
|
||||
if (status_len <= 4) {
|
||||
char *new_sc = NULL;
|
||||
size_t new_sc_len = 0;
|
||||
size_t sc_len = 0;
|
||||
uint16_t sc_len = 0;
|
||||
const char *sc = uwsgi_http_status_msg(status, &sc_len);
|
||||
if (sc) {
|
||||
new_sc = uwsgi_concat3n(status, 3, " ", 1, (char *)sc, sc_len);
|
||||
|
||||
@@ -163,7 +163,7 @@ func CacheDel(key string) bool {
|
||||
|
||||
C.uwsgi_cache_wlock()
|
||||
|
||||
if int(C.uwsgi_cache_del(k, C.uint16_t(kl), C.uint64_t(0))) < 0 {
|
||||
if int(C.uwsgi_cache_del(k, C.uint16_t(kl), C.uint64_t(0), C.uint16_t(0))) < 0 {
|
||||
C.uwsgi_cache_rwunlock();
|
||||
return false;
|
||||
}
|
||||
@@ -303,7 +303,6 @@ type ResponseWriter struct {
|
||||
wsgi_req *C.struct_wsgi_request
|
||||
headers http.Header
|
||||
wroteHeader bool
|
||||
headers_chunk string
|
||||
}
|
||||
|
||||
func (w *ResponseWriter) Write(p []byte) (n int, err error) {
|
||||
@@ -318,27 +317,25 @@ func (w *ResponseWriter) Write(p []byte) (n int, err error) {
|
||||
|
||||
// TODO fix it !!!
|
||||
func (w *ResponseWriter) WriteHeader(status int) {
|
||||
proto := "HTTP/1.0"
|
||||
if w.r.ProtoAtLeast(1, 1) {
|
||||
proto = "HTTP/1.1"
|
||||
}
|
||||
codestring := http.StatusText(status)
|
||||
w.headers_chunk += proto + " " + strconv.Itoa(status) + " " + codestring + "\r\n"
|
||||
c_status := C.CString(w.headers_chunk)
|
||||
C.uwsgi_response_preare_headers(w.wsgi_req, c_status, C.size_t(len(w.headers_chunk)) )
|
||||
var tmp_buf string = strconv.Itoa(status) + " " + codestring
|
||||
c_status := C.CString(tmp_buf)
|
||||
defer C.free(unsafe.Pointer(c_status))
|
||||
C.uwsgi_response_prepare_headers(w.wsgi_req, c_status, C.uint16_t(len(tmp_buf)) )
|
||||
if w.headers.Get("Content-Type") == "" {
|
||||
w.headers.Set("Content-Type", "text/html; charset=utf-8")
|
||||
}
|
||||
for k := range w.headers {
|
||||
hk_c := C.CString(k)
|
||||
defer C.free(unsafe.Pointer(hk_c))
|
||||
for _, v := range w.headers[k] {
|
||||
v = strings.NewReplacer("\n", " ", "\r", " ").Replace(v)
|
||||
v = strings.TrimSpace(v)
|
||||
w.headers_chunk += k + ": " + v + "\r\n"
|
||||
hv_c := C.CString(v)
|
||||
defer C.free(unsafe.Pointer(hv_c))
|
||||
C.uwsgi_response_add_header(w.wsgi_req, hk_c, C.uint16_t(len(k)), hv_c, C.uint16_t(len(v)))
|
||||
}
|
||||
}
|
||||
c_h_chunk := C.CString(w.headers_chunk)
|
||||
defer C.free(unsafe.Pointer(c_h_chunk))
|
||||
C.uwsgi_simple_response_write_header(w.wsgi_req, c_h_chunk, C.size_t(len(w.headers_chunk)))
|
||||
w.wroteHeader = true
|
||||
}
|
||||
|
||||
@@ -374,7 +371,7 @@ func uwsgi_go_helper_request(env *map[string]string, wsgi_req *C.struct_wsgi_req
|
||||
if err != nil {
|
||||
} else {
|
||||
httpReq.Body = &BodyReader{wsgi_req}
|
||||
w := ResponseWriter{httpReq, wsgi_req,http.Header{},false, ""}
|
||||
w := ResponseWriter{httpReq, wsgi_req,http.Header{},false}
|
||||
if uwsgi_default_request_handler != nil {
|
||||
uwsgi_default_request_handler(&w, httpReq)
|
||||
} else if uwsgi_default_handler != nil {
|
||||
|
||||
@@ -3765,7 +3765,7 @@ ssize_t uwsgi_sendfile_do(int, int, size_t, size_t);
|
||||
int uwsgi_proto_base_fix_headers(struct wsgi_request *);
|
||||
int uwsgi_response_add_content_length(struct wsgi_request *, uint64_t);
|
||||
|
||||
const char *uwsgi_http_status_msg(char *, size_t *);
|
||||
const char *uwsgi_http_status_msg(char *, uint16_t *);
|
||||
|
||||
#define uwsgi_response_add_connection_close(x) uwsgi_response_add_header(x, "Connection", 10, "close", 5)
|
||||
#define uwsgi_response_add_content_type(x, y, z) uwsgi_response_add_header(x, "Content-Type", 12, y, z)
|
||||
|
||||
Reference in New Issue
Block a user