unique_lock guard(out_headers_lock);
char line[len + 1];
-
char *s = (char *)ptr, *end = (char *)ptr + len;
char *p = line;
ldpp_dout(this, 30) << "receive_http_header" << dendl;
continue;
}
if (*s == '\n') {
+ if (p == line) {
+ // End of headers (empty line "\r\n")
+ ldpp_dout(this, 30) << "All headers received" << dendl;
+ return handle_headers(out_headers, http_status);
+ }
*p = '\0';
- ldpp_dout(this, 30) << "received header:" << line << dendl;
+ ldpp_dout(this, 30) << "received header: " << line << dendl;
// TODO: fill whatever data required here
char *l = line;
char *tok = strsep(&l, " \t:");
if (tok && l) {
while (*l == ' ')
l++;
-
+
if (strcmp(tok, "HTTP") == 0 || strncmp(tok, "HTTP/", 5) == 0) {
http_status = atoi(l);
if (http_status == 100) /* 100-continue response */
continue;
status = rgw_http_error_to_errno(http_status);
} else {
- /* convert header field name to upper case */
+ /* convert header field name to upper case */
char *src = tok;
char buf[len + 1];
size_t i;
return r;
}
}
+ p = line;
}
if (s != end)
*p++ = *s++;
}
+
return 0;
}
return status;
}
+int RGWHTTPStreamRWRequest::handle_headers(const map<string, string>& headers, int http_status)
+{
+ if (cb) {
+ return cb->handle_headers(headers, http_status);
+ }
+
+ return 0;
+}
+
int RGWHTTPStreamRWRequest::handle_header(const string& name, const string& val)
{
if (name == "RGWX_EMBEDDED_METADATA_LEN") {
bufferlist response;
virtual int handle_header(const std::string& name, const std::string& val);
+ virtual int handle_headers(const std::map<std::string, std::string>& headers, int http_status) { return 0; }
void get_params_str(std::map<std::string, std::string>& extra_args, std::string& dest);
public:
bufferlist outbl;
int handle_header(const std::string& name, const std::string& val) override;
+ int handle_headers(const std::map<std::string, std::string>& headers, int http_status) override;
public:
int send_data(void *ptr, size_t len, bool *pause) override;
int receive_data(void *ptr, size_t len, bool *pause) override;
ReceiveCB() = default;
virtual ~ReceiveCB() = default;
virtual int handle_data(bufferlist& bl, bool *pause = nullptr) = 0;
+ virtual int handle_headers(const std::map<std::string, std::string>& headers, int http_status) { return 0; }
virtual void set_extra_data_len(uint64_t len) {
extra_data_len = len;
}