Skip to content

Commit

Permalink
remove KSink::response_connection api
Browse files Browse the repository at this point in the history
  • Loading branch information
keengo99 committed Dec 10, 2024
1 parent ada73fd commit 68e7b49
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 18 deletions.
6 changes: 3 additions & 3 deletions include/KHttpRequest.h
Original file line number Diff line number Diff line change
Expand Up @@ -350,9 +350,9 @@ class KHttpRequest final : public KHttpRequestData
return sink->response_content_length(content_length);
}
//返回true,一定需要回应content-length或chunk
inline bool response_connection() {
return sink->response_connection();
}
//inline bool response_connection() {
// return sink->response_connection();
//}

/**
* if lock_header true the header param will locked by sink until startResponseBody be called.
Expand Down
4 changes: 0 additions & 4 deletions include/KSimulateRequest.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@ class KSimulateSink : public KSingleConnectionSink
return true;
}
void start(int header_len) override;
bool response_connection(const char *val, int val_len) override
{
return false;
}
//·µ»ØÍ·³¤¶È,-1±íʾ³ö´í
int internal_start_response_body(int64_t body_size, bool is_100_continue) override
{
Expand Down
2 changes: 1 addition & 1 deletion khttpd
Submodule khttpd updated from 00860c to 7e8b3d
6 changes: 3 additions & 3 deletions src/HttpCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ KGL_RESULT send_http2(KHttpRequest* rq, KHttpObject* obj, uint16_t status_code,
}
obj->ResponseVaryHeader(rq);
}
rq->response_connection();
//rq->response_connection();
rq->start_response_body(send_len);
if (body && rq->sink->data.meth != METH_HEAD) {
return rq->write_buf(body->getHead(), body->getLen());
Expand Down Expand Up @@ -354,7 +354,7 @@ bool build_obj_header(KHttpRequest* rq, KHttpObject* obj, INT64 content_len, boo
rq->response_header(kgl_header_etag, obj->data->etag->data, (int)obj->data->etag->len, true);
}
}
rq->response_connection();
//rq->response_connection();
return rq->start_response_body(content_len);
}
KGL_RESULT response_redirect(kgl_output_stream* out, const char* url, size_t url_len, uint16_t code) {
Expand All @@ -380,7 +380,7 @@ bool push_redirect_header(KHttpRequest* rq, const char* url, int url_len, int co
rq->response_header(kgl_header_date, (char*)cachedDateTime, 29);
timeLock.Unlock();
rq->response_header(kgl_expand_string("Location"), url, url_len);
rq->response_connection();
//rq->response_connection();
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/HttpFiber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ KGL_RESULT response_cache_object(KHttpRequest* rq, KHttpObject* obj) {
rq->response_status(STATUS_RANGE_NOT_SATISFIABLE);
rq->response_content_range(nullptr, content_length);
rq->response_header(kgl_header_content_length, _KS("0"), true);
rq->response_connection();
//rq->response_connection();
rq->start_response_body(0);
goto done;
}
Expand Down
1 change: 0 additions & 1 deletion src/KHttpManage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1018,7 +1018,6 @@ bool KHttpManage::sendMainPage() {
bool KHttpManage::sendRedirect(const char* newUrl) {
rq->response_status(STATUS_FOUND);
rq->response_header(kgl_expand_string("Content-Length"), 0);
rq->response_connection();
rq->response_header(kgl_expand_string("Location"), newUrl, (hlen_t)strlen(newUrl));
return rq->start_response_body(0);
}
Expand Down
2 changes: 0 additions & 2 deletions src/KPushGate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -490,14 +490,12 @@ kgl_response_body_function kgl_default_response_body = {
KGL_RESULT check_write_header_finish(kgl_output_stream_ctx* st, int64_t body_size, kgl_response_body* body) {
KHttpRequest* rq = (KHttpRequest*)st;
if (is_status_code_no_body(rq->sink->data.status_code)) {
rq->response_connection();
if (!rq->start_response_body(0)) {
return KGL_EINVALID_PARAMETER;
}
return KGL_NO_BODY;
}
rq->response_content_length(body_size);
rq->response_connection();
if (!rq->start_response_body(body_size)) {
return KGL_EINVALID_PARAMETER;
}
Expand Down
1 change: 0 additions & 1 deletion test/test_child/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ static void krequest_start(KSink* sink, int header_len)
{
klog(KLOG_NOTICE, "meth=[%d] path=[%s]\n", sink->data.meth, sink->data.raw_url.path);
sink->response_status(200);
sink->response_connection();
char buf[128];
int len = snprintf(buf, sizeof(buf), "hello %d %d", getpid(), (int)time(NULL));
sink->response_content_length(len);
Expand Down
4 changes: 2 additions & 2 deletions test/test_framework/base_suite/100_continue.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package base_suite
import (
"bufio"
"fmt"
"io/ioutil"
"io"
"net"
"net/http"
"strings"
Expand All @@ -13,7 +13,7 @@ import (

func handle_100_continue(w http.ResponseWriter, r *http.Request) {
if r.Header.Get("x-read-body") == "1" {
buf, _ := ioutil.ReadAll(r.Body)
buf, _ := io.ReadAll(r.Body)
w.Write(buf)
return
}
Expand Down

0 comments on commit 68e7b49

Please sign in to comment.