Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
109 commits
Select commit Hold shift + click to select a range
072d775
Merge pull request #5 from rahul1aggarwal/hammer
harshalgupta Apr 22, 2016
3049ff2
Merge pull request #6 from jiocloudDSS/hammer
harshalgupta Jun 2, 2016
093b9d2
Merge branch 'hammer' of https://github.com/jiocloudDSS/ceph into hammer
harshalgupta Jun 3, 2016
477c429
common/*Formatters: Split Formatters
Aug 24, 2015
cc544de
common/HTMLFormatter: add new formatter
Aug 24, 2015
a228e45
common/*Formatters: handling of headers & footers.
Aug 24, 2015
c0bacef
rgw: define data structures for static website config
yehudasa Nov 27, 2014
b0b8852
rgw: retarget requests
yehudasa Mar 20, 2015
480a55d
rgw: initial implementation of website REST api
yehudasa Mar 20, 2015
f95971d
rgw: enable website as subresource
yehudasa Mar 20, 2015
a50fb35
rgw: xml encoder / decoder
yehudasa Mar 23, 2015
733e0b0
rgw: add xml encoders for website conf
yehudasa Mar 23, 2015
b97ed05
rgw: set bucket website operation
yehudasa Mar 23, 2015
e2d4eb5
rgw: no need to explicitly allocate XMLObj
yehudasa Mar 23, 2015
5b39d03
rgw: fix xml encoding for certain website operations
yehudasa Mar 24, 2015
55bd0c1
rgw: add remove website api
yehudasa Mar 24, 2015
ec07cbc
rgw: apply redirect rules in static website
yehudasa Mar 27, 2015
9b7d287
rgw-website: do not truncate nuke key if valid.
robbat2 Jun 6, 2015
8e30ae7
rgw-website: ListBucket not valid for websites
robbat2 Jun 6, 2015
42e60b1
rgw-website: cleanup unused variable: rules
robbat2 Jun 6, 2015
6b6c907
rgw-website: Do not apply retarget for an authenticated request.
robbat2 Jun 9, 2015
2fa0e81
rgw-website: Use default hostname/protocol if redirect does not specify.
robbat2 Jun 9, 2015
2dbff7b
rgw-website: append the key, not overwrite.
robbat2 Jun 9, 2015
910df9c
rgw-website: handle redirect_all via RGWBWRoutingRule.
robbat2 Jun 9, 2015
20f4d6c
rgw: Add note about future rgw performance optimization for regions w…
robbat2 Jun 10, 2015
ef99455
RGWRegion: AmazonS3 detects website endpoint storage
robbat2 Jun 10, 2015
839396d
rgw: Document rgw_dns_name
robbat2 Jun 10, 2015
a40c77c
WIP-FIXME-TODO: Planning for hostname/endpoints specific to APIs.
robbat2 Jun 10, 2015
2b29031
WIP-FIXME: Static fetch works without breaking anything else, uses bu…
robbat2 Jun 9, 2015
1743099
FIXUP: Fix comment.
robbat2 Jun 13, 2015
31f48e1
rgw: use new formatter header/footer ability.
robbat2 Jun 14, 2015
2af40fe
rgw: More fields in error output to match main S3.
robbat2 Jun 14, 2015
2933d51
rgw: pretty-print s3website error output.
robbat2 Jun 14, 2015
f2f9403
More s3website json region data.
robbat2 Jun 14, 2015
3bce08d
rgw: tweak dns-based s3website detection for other changes FIXME-REBASE
robbat2 Jun 14, 2015
daa2487
Avoid dupe reset.
robbat2 Jun 14, 2015
d91b5d5
WIP-FIXUP: Muck with bucket detection again.
robbat2 Jun 14, 2015
e7d622a
DEBUG: Ensure we always go past the debug output for now.
robbat2 Jun 14, 2015
4d01190
Optimize website detection differently.
robbat2 Jun 14, 2015
a121270
Add error codes.
robbat2 Jun 14, 2015
d1dd9db
FIXUP: Shuffle auth order back down.
robbat2 Jun 14, 2015
ebb4db7
Improve RGWHandler for S3Website.
robbat2 Jun 14, 2015
555cc89
Remove config rgw_s3website_mode, only hostname mode remains.
robbat2 Jun 14, 2015
db313b3
Clean up headers.
robbat2 Jun 14, 2015
f10c557
Mark where to add some functionality in future.
robbat2 Jun 14, 2015
82b88d1
rgw: add 301 http text.
robbat2 Jun 16, 2015
42c8cd2
rgw: prepare for handlers to have custom error handler routines
robbat2 Jun 16, 2015
cd5a2ad
RGWWebsite: first pass at error redirect and error page handling.
robbat2 Jun 16, 2015
3ad7bb3
S3Website: Ensure redirect_all has a 302 response, just like AmazonS3
robbat2 Jun 17, 2015
2c685e2
S3Website: "good" error status is actually not zero, use the function…
robbat2 Jun 17, 2015
60b0662
s3website: Prepwork for x-amz-website-redirect-location header.
robbat2 Jun 22, 2015
61ee452
Use more specific error codes for retarget of website requests
robbat2 Jun 28, 2015
7b0a7b6
WIP: static-site errordoc work.
robbat2 Aug 18, 2015
eef7145
Fixup.
Aug 24, 2015
e407fb9
minor fixes following rebase
yehudasa Oct 12, 2015
084abb4
rgw: style fixes
yehudasa Oct 12, 2015
37b09c5
rgw: more style fixes
yehudasa Oct 12, 2015
f890b62
rgw/Makefile.am: declare rgw_website.h for buildfix.
Nov 24, 2015
468202b
rgw/Makefile.am: declare rgw_rest_s3website.h as well for bugfixing.
Nov 25, 2015
071ff6e
src/*/Makefile.am: test fixup for as-needed compiling.
Nov 26, 2015
908f81c
rgw/s3website: errordoc conditional handling
Nov 30, 2015
e4725b6
Revert "common/*Formatters: Split Formatters"
yehudasa Jan 15, 2016
f52881e
Undo constant renaming: RGW_REST_*->RGW_PROTO_*.
Dec 3, 2015
97675a1
undo: clean up dead enum RGWEndpointType.
Dec 3, 2015
9bcc07d
cleanup: remove dead function.
Dec 3, 2015
9f063ca
Copyright: add copyright blocks to new files, and update files with e…
Dec 4, 2015
66345a2
s3website: update cmake.
Dec 4, 2015
d682f10
rgw: remove split formatter code
yehudasa Jan 19, 2016
a5abe3b
DSS Changes for merging formatters. Instead of big PR 7381 on upstream
bafna Jun 20, 2016
5aa0b04
rgw: init_permissions() shouldn't return ENOENT in a specific case
yehudasa Jan 19, 2016
867afa4
S3Website: AmazonS3 changed RedirectAll HTTP response.
Jan 7, 2016
999e8f9
rgw: add explicit success/error paths in RGWGetObj::execute()
jmunhoz Oct 21, 2015
bcf8ae6
WIP x-amz-website-redirect-location . Backported from 11913b964220e74…
bafna Jun 21, 2016
18e83c1
rgw: a few minor cleanups
yehudasa Jan 20, 2016
1496213
rgw: client io shouldn't try to write zero length buffer
yehudasa Jan 20, 2016
9eadab8
rgw: fix create bucket error handling
yehudasa Jan 20, 2016
b623106
rgw: add a configurable to enable/disable static website
yehudasa Jan 22, 2016
661c8b9
rgw/s3website: Fix x-amz-website-redirect-location support.
Apr 17, 2016
8b77bc0
rgw/s3website: Implement ErrorDoc & fix Double-Fault handler
Apr 20, 2016
bcd5d2e
Merge branch 'hammer' of https://github.com/jiocloudDSS/ceph into hammer
harshalgupta Jun 22, 2016
490a4f5
rgw/s3website: whitespace style fixes
May 18, 2016
e4aa51e
rgw: fix manager selection when APIs customized
May 20, 2016
7d84110
Fixing HTPP return code and formatting error
bafna Jun 27, 2016
9e286e4
Removing useless file
bafna Jul 6, 2016
72c48ee
Fixing the prefix to jcs
bafna Jul 7, 2016
4a316bc
Merge pull request #7 from jiocloudDSS/hammer
harshalgupta Jul 7, 2016
fe98068
Merge branch 'hammer' of https://github.com/jiocloudDSS/ceph into hammer
harshalgupta Aug 3, 2016
37eadf8
Fixing the bug in rename API where original name contains '%' character
harshalgupta Aug 4, 2016
5b390df
Merge branch 'hammer' of https://github.com/harshalgupta/ceph into ha…
harshalgupta Aug 4, 2016
8e83710
Merge pull request #62 from harshalgupta/hammer
bafna Aug 4, 2016
5ca2d02
Adding some additional logs for testing Rename API
harshalgupta Aug 4, 2016
077662d
fixing some typo in the previous commit
harshalgupta Aug 4, 2016
cf419b3
Merge pull request #63 from harshalgupta/hammer
harshalgupta Aug 4, 2016
5ecbaab
Merge pull request #64 from bafna/hammer-j
bafna Sep 26, 2016
a9ca0a7
Merge pull request #68 from bafna/hammer-j
bafna Oct 1, 2016
5a7a9d4
Merge pull request #69 from bafna/hammer-j
harshalgupta Oct 10, 2016
fd1e8ee
Fixing an issue where 'x-jcs-*' headers are modified and all 'x-*' p…
harshalgupta Oct 10, 2016
0a8bc3c
Logging Source IP of user and sending it to IAM
harshalgupta Oct 12, 2016
a6fc162
Merge branch 'hammer' of https://github.com/jioclouddss/ceph into sou…
harshalgupta Oct 12, 2016
50cff68
Merge pull request #72 from bafna/sourceip
harshalgupta Oct 13, 2016
7e6bb21
Merge branch 'hammer' of https://github.com/jiocloudDSS/ceph into hammer
harshalgupta Oct 20, 2016
b395c16
Adding a header for encrypted objects Get/Head Ops
harshalgupta Oct 21, 2016
be50ad6
Merge pull request #73 from bafna/sourceip
harshalgupta Oct 21, 2016
3203742
Adding x-jcs-server-side-encryption as a special case header which wi…
harshalgupta Oct 26, 2016
d7e2aaa
Merge pull request #74 from harshalgupta/hammer
bafna Oct 26, 2016
9d2101c
adding error code for wrong encryption header
harshalgupta Oct 26, 2016
4ad70a4
Merge pull request #75 from harshalgupta/hammer
harshalgupta Oct 26, 2016
ef1fed4
Overriding denial of permission by ACL
harshalgupta Dec 29, 2016
f6127c5
Resolving conflicts and allowing anon user for website access
harshalgupta Dec 29, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ set(libcommon_files
common/simple_spin.cc
common/Thread.cc
common/Formatter.cc
common/HTMLFormatter.cc
common/HeartbeatMap.cc
common/ceph_fs.cc
common/ceph_hash.cc
Expand Down Expand Up @@ -732,7 +733,9 @@ if(${WITH_RADOSGW})
rgw/rgw_replica_log.cc
rgw/rgw_keystone.cc
rgw/rgw_quota.cc
rgw/rgw_dencoder.cc)
rgw/rgw_dencoder.cc
rgw/rgw_website.cc
rgw/rgw_xml_enc.cc)

add_library(rgw_a STATIC ${rgw_a_srcs})

Expand Down
32 changes: 28 additions & 4 deletions src/common/Formatter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include "assert.h"
#include "Formatter.h"
#include "HTMLFormatter.h"
#include "common/escape.h"

#include <iostream>
Expand Down Expand Up @@ -83,6 +84,10 @@ Formatter *Formatter::create(const std::string &type,
return new TableFormatter();
else if (mytype == "table-kv")
return new TableFormatter(true);
else if (mytype == "html")
return new HTMLFormatter(false);
else if (mytype == "html-pretty")
return new HTMLFormatter(true);
else if (fallback != "")
return create(fallback, "", "");
else
Expand Down Expand Up @@ -126,8 +131,6 @@ void JSONFormatter::flush(std::ostream& os)
{
finish_pending_string();
os << m_ss.str();
if (m_pretty)
os << "\n";
m_ss.clear();
m_ss.str("");
}
Expand Down Expand Up @@ -317,8 +320,11 @@ XMLFormatter::XMLFormatter(bool pretty)
void XMLFormatter::flush(std::ostream& os)
{
finish_pending_string();
os << m_ss.str();
if (m_pretty)
std::string m_ss_str = m_ss.str();
os << m_ss_str;
/* There is a small catch here. If the rest of the formatter had NO output,
* we should NOT output a newline. This primarily triggers on HTTP redirects */
if (m_pretty && !m_ss_str.empty())
os << "\n";
m_ss.clear();
m_ss.str("");
Expand All @@ -332,6 +338,24 @@ void XMLFormatter::reset()
m_pending_string.str("");
m_sections.clear();
m_pending_string_name.clear();
m_header_done = false;
}

void XMLFormatter::output_header()
{
if(!m_header_done) {
m_header_done = true;
write_raw_data(XMLFormatter::XML_1_DTD);;
if (m_pretty)
m_ss << "\n";
}
}

void XMLFormatter::output_footer()
{
while(!m_sections.empty()) {
close_section();
}
}

void XMLFormatter::open_object_section(const char *name)
Expand Down
20 changes: 17 additions & 3 deletions src/common/Formatter.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ namespace ceph {
}
virtual void reset() = 0;

virtual void set_status(const char* status, const char* status_name) = 0;
virtual void output_header() = 0;
virtual void output_footer() = 0;

virtual void open_array_section(const char *name) = 0;
virtual void open_array_section_in_ns(const char *name, const char *ns) = 0;
virtual void open_object_section(const char *name) = 0;
Expand Down Expand Up @@ -88,7 +92,9 @@ namespace ceph {
class JSONFormatter : public Formatter {
public:
JSONFormatter(bool p = false);

virtual void set_status(const char* status, const char* status_name) {};
virtual void output_header() {};
virtual void output_footer() {};
void flush(std::ostream& os);
void reset();
virtual void open_array_section(const char *name);
Expand Down Expand Up @@ -130,6 +136,10 @@ namespace ceph {
static const char *XML_1_DTD;
XMLFormatter(bool pretty = false);

virtual void set_status(const char* status, const char* status_name) {};
virtual void output_header();
virtual void output_footer();

void flush(std::ostream& os);
void reset();
void open_array_section(const char *name);
Expand All @@ -150,7 +160,7 @@ namespace ceph {
void open_array_section_with_attrs(const char *name, const FormatterAttrs& attrs);
void open_object_section_with_attrs(const char *name, const FormatterAttrs& attrs);
void dump_string_with_attrs(const char *name, const std::string& s, const FormatterAttrs& attrs);
private:
protected:
void open_section_in_ns(const char *name, const char *ns, const FormatterAttrs *attrs);
void finish_pending_string();
void print_spaces();
Expand All @@ -161,12 +171,16 @@ namespace ceph {
std::deque<std::string> m_sections;
bool m_pretty;
std::string m_pending_string_name;
bool m_header_done;
};

class TableFormatter : public Formatter {
public:
TableFormatter(bool keyval = false);


virtual void set_status(const char* status, const char* status_name) {};
virtual void output_header() {};
virtual void output_footer() {};
void flush(std::ostream& os);
void reset();
virtual void open_array_section(const char *name);
Expand Down
165 changes: 165 additions & 0 deletions src/common/HTMLFormatter.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2011 New Dream Network
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/

#define LARGE_SIZE 1024

#include "include/int_types.h"

#include "assert.h"
#include "Formatter.h"
#include "HTMLFormatter.h"
#include "common/escape.h"

#include <iostream>
#include <sstream>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <string>
#include <set>
#include <boost/format.hpp>

// -----------------------
namespace ceph {

HTMLFormatter::HTMLFormatter(bool pretty)
: XMLFormatter(pretty), m_header_done(false), m_status(NULL), m_status_name(NULL)
{
}

HTMLFormatter::~HTMLFormatter()
{
if (m_status) {
free((void*)m_status);
m_status = NULL;
}
if (m_status_name) {
free((void*)m_status_name);
m_status_name = NULL;
}
}

void HTMLFormatter::reset()
{
XMLFormatter::reset();
m_header_done = false;
if (m_status) {
free((void*)m_status);
m_status = NULL;
}
if (m_status_name) {
free((void*)m_status_name);
m_status_name = NULL;
}
}

void HTMLFormatter::set_status(const char* status, const char* status_name)
{
assert(status != NULL); // new status must not be NULL
assert(m_status == NULL); // status should NOT be set multiple times
m_status = strdup(status);
if (status_name)
m_status_name = strdup(status_name);
};

void HTMLFormatter::output_header() {
if (!m_header_done) {
m_header_done = true;
assert(m_status != NULL); // it should be set by this point
std::string status_line(m_status);
if (m_status_name) {
status_line += " ";
status_line += m_status_name;
}
open_object_section("html");
print_spaces();
m_ss << "<head><title>" << status_line << "</title></head>";
if (m_pretty)
m_ss << "\n";
open_object_section("body");
print_spaces();
m_ss << "<h1>" << status_line << "</h1>";
if (m_pretty)
m_ss << "\n";
open_object_section("ul");
}
}

template <typename T>
void HTMLFormatter::dump_template(const char *name, T arg)
{
print_spaces();
m_ss << "<li>" << name << ": " << arg << "</li>";
if (m_pretty)
m_ss << "\n";
}

void HTMLFormatter::dump_unsigned(const char *name, uint64_t u)
{
dump_template(name, u);
}

void HTMLFormatter::dump_int(const char *name, int64_t u)
{
dump_template(name, u);
}

void HTMLFormatter::dump_float(const char *name, double d)
{
dump_template(name, d);
}

void HTMLFormatter::dump_string(const char *name, const std::string& s)
{
dump_template(name, escape_xml_str(s.c_str()));
}

void HTMLFormatter::dump_string_with_attrs(const char *name, const std::string& s, const FormatterAttrs& attrs)
{
std::string e(name);
std::string attrs_str;
get_attrs_str(&attrs, attrs_str);
print_spaces();
m_ss << "<li>" << e << ": " << escape_xml_str(s.c_str()) << attrs_str << "</li>";
if (m_pretty)
m_ss << "\n";
}

std::ostream& HTMLFormatter::dump_stream(const char *name)
{
print_spaces();
m_pending_string_name = "li";
m_ss << "<li>" << name << ": ";
return m_pending_string;
}

void HTMLFormatter::dump_format_va(const char* name, const char *ns, bool quoted, const char *fmt, va_list ap)
{
char buf[LARGE_SIZE];
vsnprintf(buf, LARGE_SIZE, fmt, ap);

std::string e(name);
print_spaces();
if (ns) {
m_ss << "<li xmlns=\"" << ns << "\">" << e << ": " << escape_xml_str(buf) << "</li>";
} else {
m_ss << "<li>" << e << ": " << escape_xml_str(buf) << "</li>";
}

if (m_pretty)
m_ss << "\n";
}

} // namespace ceph
50 changes: 50 additions & 0 deletions src/common/HTMLFormatter.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
#ifndef CEPH_HTML_FORMATTER_H
#define CEPH_HTML_FORMATTER_H

#include "include/int_types.h"

#include <deque>
#include <iosfwd>
#include <list>
#include <vector>
#include <sstream>
#include <stdarg.h>
#include <string>
#include <map>

#include "include/buffer.h"
#include "Formatter.h"

namespace ceph {
class HTMLFormatter : public XMLFormatter {
public:
HTMLFormatter(bool pretty = false);
~HTMLFormatter();
void reset();

virtual void set_status(const char* status, const char* status_name);
virtual void output_header();

void dump_unsigned(const char *name, uint64_t u);
void dump_int(const char *name, int64_t u);
void dump_float(const char *name, double d);
void dump_string(const char *name, const std::string& s);
std::ostream& dump_stream(const char *name);
void dump_format_va(const char *name, const char *ns, bool quoted, const char *fmt, va_list ap);

/* with attrs */
void dump_string_with_attrs(const char *name, const std::string& s, const FormatterAttrs& attrs);
private:
template <typename T> void dump_template(const char *name, T arg);

bool m_header_done;

const char* m_status;
const char* m_status_name;
};

}

#endif
2 changes: 2 additions & 0 deletions src/common/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ libcommon_internal_la_SOURCES = \
common/simple_spin.cc \
common/Thread.cc \
common/Formatter.cc \
common/HTMLFormatter.cc \
common/HeartbeatMap.cc \
common/config.cc \
common/utf8.c \
Expand Down Expand Up @@ -178,6 +179,7 @@ noinst_HEADERS += \
common/DecayCounter.h \
common/Finisher.h \
common/Formatter.h \
common/HTMLFormatter.h \
common/perf_counters.h \
common/OutputDataSocket.h \
common/admin_socket.h \
Expand Down
Loading