stub_libhttp.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2019 The Squid Software Foundation and contributors
3  *
4  * Squid software is distributed under GPLv2+ license and includes
5  * contributions from numerous individuals and organizations.
6  * Please see the COPYING and CONTRIBUTORS files for details.
7  */
8 
9 #include "squid.h"
10 #include "client_side.h"
11 #include "comm/Connection.h"
12 #include "SquidConfig.h"
13 
14 #define STUB_API "http/libhttp.la"
15 #include "STUB.h"
16 
18 namespace Http
19 {
20 // XXX: use C++11 initialization for this class
22  value(-1),
23  headerWideProblem(nullptr),
24  debugLevel(Config.onoff.relaxed_header_parser <= 0 ? DBG_IMPORTANT : 2),
25  sawBad(false),
26  needsSanitizing(false),
27  sawGood(false),
28  prohibitedAndIgnored_(nullptr)
29 {
30 }
32 bool ContentLengthInterpreter::goodSuffix(const char *, const char * const) const STUB_RETVAL(false)
33 bool ContentLengthInterpreter::checkValue(const char *, const int) STUB_RETVAL(false)
35 }
36 
37 #include "http/Message.h"
38 namespace Http
39 {
42 void Message::packInto(Packable *, bool) const STUB
43 void Message::setContentLength(int64_t) STUB
44 bool Message::persistent() const STUB_RETVAL(false)
45 void Message::putCc(const HttpHdrCc *) STUB
46 bool Message::parse(const char *, const size_t, bool, Http::StatusCode *) STUB_RETVAL(false)
47 bool Message::parseCharBuf(const char *, ssize_t) STUB_RETVAL(false)
48 int Message::httpMsgParseStep(const char *, int, int) STUB_RETVAL(-1)
53 }
54 
55 #include "http/MethodType.h"
56 namespace Http
57 {
58 const SBuf MethodType_sb[1] = {SBuf()};
59 }
60 
61 #include "http/RegisteredHeaders.h"
62 namespace Http
63 {
68 const HeaderTableRecord& HeaderLookupTable_t::lookup(const char *, const std::size_t) const STUB_RETVAL(BadHdr)
70 }
71 std::ostream &operator<< (std::ostream&os, Http::HdrType) STUB_RETVAL(os)
72 
73 #include "http/RequestMethod.h"
76 const SBuf &HttpRequestMethod::image() const STUB_RETVAL(theImage)
82 
83 #include "http/StatusCode.h"
84 namespace Http
85 {
86 const char *StatusCodeString(const Http::StatusCode) STUB_RETVAL(nullptr)
87 }
88 
89 #include "http/StatusLine.h"
90 namespace Http
91 {
95 const char *StatusLine::reason() const STUB_RETVAL(nullptr)
97 bool StatusLine::parse(const String &, const char *, const char *) STUB_RETVAL(false)
98 }
99 
100 #include "http/Stream.h"
101 namespace Http
102 {
106 bool Stream::startOfOutput() const STUB
107 void Stream::writeComplete(size_t) STUB
108 void Stream::pullData() STUB
109 bool Stream::multipartRangeRequest() const STUB_RETVAL(false)
110 int64_t Stream::getNextRangeOffset() const STUB_RETVAL(-1)
111 bool Stream::canPackMoreRanges() const STUB_RETVAL(false)
112 size_t Stream::lengthToSend(Range<int64_t> const &) const STUB_RETVAL(0)
116 void Stream::noteSentBodyBytes(size_t) STUB
120 ConnStateData *Stream::getConn() const STUB_RETVAL(nullptr)
121 void Stream::noteIoError(const int) STUB
122 void Stream::finished() STUB
123 void Stream::initiateClose(const char *) STUB
125 }
126 
void sendBody(StoreIOBuffer bodyData)
send some HTTP reply message payload
Definition: Stream.cc:316
void clean()
reset this status-line back to Internal Server Error state
Definition: StatusLine.cc:23
void writeComplete(size_t size)
update stream state after a write, may initiate more I/O
Definition: Stream.cc:67
void noteIoError(const int xerrno)
update state to reflect I/O error
Definition: Stream.cc:561
bool isIdempotent() const
const char * StatusCodeString(const Http::StatusCode status)
Definition: stub_libhttp.cc:86
const char * reason() const
retrieve the reason string for this status line
Definition: StatusLine.cc:40
const HeaderTableRecord & lookup(const char *buf, const std::size_t len) const
look record type up by name (C-string and length)
http_hdr_owner_type
Definition: HttpHeader.h:31
bool canPackMoreRanges() const
Definition: Stream.cc:191
size_t lengthToSend(Range< int64_t > const &available) const
Definition: Stream.cc:339
void deferRecipientForLater(clientStreamNode *, HttpReply *, StoreIOBuffer receivedData)
Definition: Stream.cc:592
clientStream_status_t socketState()
Adapt stream status to account for Range cases.
Definition: Stream.cc:213
void set(const AnyP::ProtocolVersion &newVersion, Http::StatusCode newStatus, const char *newReason=NULL)
Definition: StatusLine.cc:30
bool persistent() const
Definition: Message.cc:261
Definition: SBuf.h:86
void firstLineBuf(MemBuf &)
useful for debugging
Definition: Message.cc:295
clientStreamNode * getTail() const
Definition: Stream.cc:538
void sendStartOfMessage(HttpReply *, StoreIOBuffer bodyData)
send an HTTP reply message headers and maybe some initial payload
Definition: Stream.cc:265
Definition: Range.h:18
void registerWithConn()
register this stream with the Server
Definition: Stream.cc:52
bool purgesOthers() const
struct SquidConfig::@111 onoff
void init()
reset this status-line back to empty state
Definition: StatusLine.cc:17
StatusCode
Definition: StatusCode.h:20
std::ostream & operator<<(std::ostream &, const Http::TunnelerAnswer &)
bool checkList(const String &list)
handles Content-Length: a, b, c
bool multipartRangeRequest() const
Definition: Stream.cc:129
int relaxed_header_parser
Definition: SquidConfig.h:318
#define STUB_RETVAL(x)
Definition: STUB.h:41
void finished()
cleanup when the transaction has finished. may destroy &#39;this&#39;
Definition: Stream.cc:571
#define DBG_IMPORTANT
Definition: Debug.h:46
Stream(const Comm::ConnectionPointer &aConn, ClientHttpRequest *aReq)
construct with HTTP/1.x details
Definition: Stream.cc:23
bool goodSuffix(const char *suffix, const char *const end) const
checks whether all characters after the Content-Length are allowed
#define STUB
macro to stub a void function.
Definition: STUB.h:33
bool parse(const String &protoPrefix, const char *start, const char *end)
Definition: StatusLine.cc:75
bool startOfOutput() const
whether the reply has started being sent
Definition: Stream.cc:61
bool parseHeader(Http1::Parser &, Http::ContentLengthInterpreter &)
Definition: Message.cc:226
clientStream_status_t
Definition: enums.h:121
clientStreamNode * getClientReplyContext() const
Definition: Stream.cc:547
void setContentLength(int64_t)
[re]sets Content-Length header and cached value
Definition: Message.cc:253
const SBuf & image() const
void packInto(Packable *, bool full_uri) const
produce a message copy, except for a few connection-specific settings
Definition: Message.cc:278
void buildRangeHeader(HttpReply *)
add Range headers (if any) to the given HTTP reply message
Definition: Stream.cc:418
void initiateClose(const char *reason)
terminate due to a send/write error (may continue reading)
Definition: Stream.cc:585
void putCc(const HttpHdrCc *otherCc)
copies Cache-Control header to this message
Definition: Message.cc:34
const HeaderLookupTable_t HeaderLookupTable
void HttpRequestMethodXXX(char const *)
ConnStateData * getConn() const
Definition: Stream.cc:553
bool checkValue(const char *start, const int size)
bool shouldInvalidate() const
int const char size_t
Definition: stub_liblog.cc:86
Definition: MemBuf.h:23
bool parseCharBuf(const char *buf, ssize_t end)
Definition: Message.cc:148
virtual ~Message()
Definition: Message.cc:28
int httpMsgParseStep(const char *buf, int len, int atEnd)
Definition: Message.cc:170
virtual void hdrCacheInit()
Definition: Message.cc:286
bool parse(const char *buf, const size_t sz, bool eol, Http::StatusCode *error)
Definition: Message.cc:80
#define STUB_NOP
Definition: STUB.h:37
virtual int httpMsgParseError()
Definition: Message.cc:246
void packInto(Packable *) const
pack fields into a Packable object
Definition: StatusLine.cc:46
void pullData()
get more data to send
Definition: Stream.cc:113
Definition: forward.h:21
const SBuf MethodType_sb[]
Definition: stub_libhttp.cc:58
bool respMaybeCacheable() const
class SquidConfig Config
Definition: SquidConfig.cc:12
Message(http_hdr_owner_type)
Definition: Message.cc:23
bool isHttpSafe() const
int64_t getNextRangeOffset() const
Definition: Stream.cc:135
void noteSentBodyBytes(size_t)
Definition: Stream.cc:362

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors