MCPcopy Create free account
hub / github.com/alibaba/PhotonLibOS / insert

Method insert

net/http/headers.cpp:79–97  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

77}
78
79int HeadersBase::insert(std::string_view key, std::string_view value, int allow_dup) {
80 if (!allow_dup) {
81 auto it = find(key);
82 if (it != end()) return -EEXIST;
83 }
84 uint64_t vbegin = m_buf_size + key.size() + 2;
85 uint64_t new_size = vbegin + value.size() + 2;
86 if (new_size + (m_kv_size + 1) * sizeof(KV) > m_buf_capacity)
87 LOG_ERROR_RETURN(ENOBUFS, -1, "no buffer");
88 auto ptr = m_buf + m_buf_size;
89 buf_append(ptr, key);
90 buf_append(ptr, ": ");
91 buf_append(ptr, value);
92 buf_append(ptr, "\r\n");
93 m_last_kv = kv_add_sort({{m_buf_size, (uint16_t)key.size()},
94 {(uint16_t)vbegin, (uint16_t)value.size()}}) - kv_begin();
95 m_buf_size = (uint16_t)new_size;
96 return 0;
97}
98
99bool HeadersBase::value_append(std::string_view value) {
100 if (m_last_kv >= m_kv_size) return false;

Callers 15

do_list_objects_v2Method · 0.45
do_list_objects_v1Method · 0.45
do_copy_objectMethod · 0.45
do_delete_objectsMethod · 0.45
put_symlinkMethod · 0.45
get_object_rangeMethod · 0.45
batch_get_objectsMethod · 0.45
put_objectMethod · 0.45
append_objectMethod · 0.45
init_multipart_uploadMethod · 0.45
upload_part_copyMethod · 0.45
sign_v1Method · 0.45

Calls 2

buf_appendFunction · 0.70
sizeMethod · 0.45

Tested by 11

handle_requestMethod · 0.36
op_proxy_directorFunction · 0.36
op_proxy_modifierFunction · 0.36
idiot_handlerFunction · 0.36
idiot_handleFunction · 0.36
body_check_handlerFunction · 0.36
test_directorFunction · 0.36
test_modifierFunction · 0.36
test_forward_directorFunction · 0.36
TESTFunction · 0.36
handle_requestMethod · 0.36