Public Member Functions | Data Fields | Protected Member Functions | Static Protected Attributes | Friends

HTTPHdr Class Reference

#include <HTTP.h>

Inherits MIMEHdr.

Collaboration diagram for HTTPHdr:
Collaboration graph
[legend]

Public Member Functions

 HTTPHdr ()
 ~HTTPHdr ()
int valid () const
void create (HTTPType polarity, HdrHeap *heap=NULL)
void clear ()
void reset ()
void copy (const HTTPHdr *hdr)
void copy_shallow (const HTTPHdr *hdr)
int unmarshal (char *buf, int len, RefCountObj *block_ref)
int print (char *buf, int bufsize, int *bufindex, int *dumpoffset)
int length_get ()
HTTPType type_get () const
HTTPVersion version_get ()
void version_set (HTTPVersion version)
const char * method_get (int *length)
int method_get_wksidx ()
void method_set (const char *value, int length)
URLurl_create (URL *url)
URLurl_get () const
URLurl_get (URL *url)
char * url_string_get (Arena *arena=0, int *length=0)
 Get a string with the effective URL in it.
char * url_string_get_ref (int *length=0)
 Get a string with the effective URL in it.
int url_print (char *buff, int length, int *offset, int *skip)
 Print the URL.
char const * path_get (int *length)
 Get the URL path.
char const * host_get (int *length=0)
 Get the target host name.
int port_get ()
 Get the target port.
char const * scheme_get (int *length)
 Get the URL scheme.
void url_set (URL *url)
void url_set_as_server_url (URL *url)
void url_set (const char *str, int length)
bool is_target_in_url () const
 Check location of target host.
bool is_port_in_header () const
 Check if a port was specified in the target.
void set_url_target_from_host_field (URL *url=0)
 If the target is in the fields and not the URL, copy it to the url.
void mark_target_dirty () const
 Mark the target cache as invalid.
HTTPStatus status_get ()
void status_set (HTTPStatus status)
const char * reason_get (int *length)
void reason_set (const char *value, int length)
MIMEParseResult parse_req (HTTPParser *parser, const char **start, const char *end, bool eof)
MIMEParseResult parse_resp (HTTPParser *parser, const char **start, const char *end, bool eof)
MIMEParseResult parse_req (HTTPParser *parser, IOBufferReader *r, int *bytes_used, bool eof)
MIMEParseResult parse_resp (HTTPParser *parser, IOBufferReader *r, int *bytes_used, bool eof)
bool is_cache_control_set (const char *cc_directive_wks)
bool is_pragma_no_cache_set ()

Data Fields

HTTPHdrImplm_http
URL m_url_cached
MIMEFieldm_host_mime
int m_host_length
 Length of hostname.
int m_port
 Target port.
bool m_target_cached
 Whether host name and port are cached.
bool m_target_in_url
 Whether host name and port are in the URL.
bool m_port_in_header
 Set if the port was effectively specified in the header.

Protected Member Functions

void _fill_target_cache () const
 Load the target cache.
void _test_and_fill_target_cache () const
 Test the cache and fill it if necessary.

Static Protected Attributes

static Arena *const USE_HDR_HEAP_MAGIC = reinterpret_cast<Arena*>(1)

Friends

class UrlPrintHack

Detailed Description

Definition at line 513 of file HTTP.h.


Constructor & Destructor Documentation

HTTPHdr::HTTPHdr (  )  [inline]

Definition at line 799 of file HTTP.h.

HTTPHdr::~HTTPHdr (  )  [inline]

Definition at line 807 of file HTTP.h.


Member Function Documentation

void HTTPHdr::_fill_target_cache (  )  const [protected]
void HTTPHdr::_test_and_fill_target_cache (  )  const [inline, protected]

Test the cache and fill it if necessary.

Definition at line 914 of file HTTP.h.

References _fill_target_cache(), and m_target_cached.

Referenced by host_get(), is_port_in_header(), is_target_in_url(), port_get(), and set_url_target_from_host_field().

void HTTPHdr::clear ( void   )  [inline]
void HTTPHdr::copy ( const HTTPHdr hdr  )  [inline]
void HTTPHdr::copy_shallow ( const HTTPHdr hdr  )  [inline]
void HTTPHdr::create ( HTTPType  polarity,
HdrHeap heap = NULL 
) [inline]
char const * HTTPHdr::host_get ( int *  length = 0  )  [inline]
bool HTTPHdr::is_cache_control_set ( const char *  cc_directive_wks  )  [inline]
bool HTTPHdr::is_port_in_header (  )  const [inline]

Check if a port was specified in the target.

Returns:
true if the port was part of the target.

Definition at line 960 of file HTTP.h.

References _test_and_fill_target_cache(), and m_port_in_header.

Referenced by HttpTransact::ModifyRequest().

bool HTTPHdr::is_pragma_no_cache_set (  )  [inline]
bool HTTPHdr::is_target_in_url (  )  const [inline]

Check location of target host.

Returns:
true if the host was in the URL, false otherwise.
Note:
This returns false if the host is missing.

Definition at line 950 of file HTTP.h.

References _test_and_fill_target_cache(), and m_target_in_url.

Referenced by HttpTransact::build_request(), HttpTransact::EndRemapRequest(), HttpTransact::ModifyRequest(), and RemapProcessor::setup_for_remap().

int HTTPHdr::length_get (  )  [inline]
void HTTPHdr::mark_target_dirty (  )  const [inline]

Mark the target cache as invalid.

Definition at line 970 of file HTTP.h.

References m_target_cached.

Referenced by RemapProcessor::finish_remap(), HttpTransact::ModifyRequest(), RemapProcessor::setup_for_remap(), TSHttpTxnClientReqGet(), and url_get().

const char * HTTPHdr::method_get ( int *  length  )  [inline]
int HTTPHdr::method_get_wksidx (  )  [inline]
void HTTPHdr::method_set ( const char *  value,
int  length 
) [inline]
MIMEParseResult HTTPHdr::parse_req ( HTTPParser parser,
const char **  start,
const char *  end,
bool  eof 
) [inline]
MIMEParseResult HTTPHdr::parse_req ( HTTPParser parser,
IOBufferReader r,
int *  bytes_used,
bool  eof 
)
MIMEParseResult HTTPHdr::parse_resp ( HTTPParser parser,
const char **  start,
const char *  end,
bool  eof 
) [inline]
MIMEParseResult HTTPHdr::parse_resp ( HTTPParser parser,
IOBufferReader r,
int *  bytes_used,
bool  eof 
)
char const * HTTPHdr::path_get ( int *  length  )  [inline]

Get the URL path.

This is a reference, not allocated.

Returns:
A pointer to the path or NULL if there is no valid URL.
Parameters:
length Storage for path length.

Definition at line 1268 of file HTTP.h.

References URL::path_get(), and url_get().

Referenced by LogAccessHttp::init().

int HTTPHdr::port_get (  )  [inline]

Get the target port.

If the target port is not found then it is adjusted to the default port for the URL type.

Note:
The results are cached so this is fast after the first call.
Returns:
The canonicalized target port.

Definition at line 940 of file HTTP.h.

References _test_and_fill_target_cache(), and m_port.

Referenced by HttpTransact::initialize_state_variables_for_origin_server(), HttpTransact::initialize_state_variables_from_request(), and RemapProcessor::setup_for_remap().

int HTTPHdr::print ( char *  buf,
int  bufsize,
int *  bufindex,
int *  dumpoffset 
) [inline]
const char * HTTPHdr::reason_get ( int *  length  )  [inline]
void HTTPHdr::reason_set ( const char *  value,
int  length 
) [inline]
void HTTPHdr::reset (  )  [inline]

Definition at line 849 of file HTTP.h.

References HdrHeapSDKHandle::m_heap, m_http, MIMEHdr::m_mime, m_url_cached, and URL::reset().

char const * HTTPHdr::scheme_get ( int *  length  )  [inline]

Get the URL scheme.

This is a reference, not allocated.

Returns:
A pointer to the scheme or NULL if there is no valid URL.
Parameters:
length Storage for path length.

Definition at line 1275 of file HTTP.h.

References URL::scheme_get(), and url_get().

Referenced by LogAccessHttp::marshal_client_req_url_scheme().

void HTTPHdr::set_url_target_from_host_field ( URL url = 0  ) 

If the target is in the fields and not the URL, copy it to the url.

If url is NULL the cached URL in this header is used.

Note:
In the default case the copy is avoided if the cached URL already has the target. If url is non NULL the copy is always performed.

Definition at line 1489 of file HTTP.cc.

References _test_and_fill_target_cache(), host_get(), URL::host_set(), m_host_length, m_host_mime, m_port, m_port_in_header, MIMEField::m_ptr_value, m_target_in_url, m_url_cached, and URL::port_set().

Referenced by HttpTransact::build_request(), HttpTransact::DecideCacheLookup(), and RemapProcessor::setup_for_remap().

HTTPStatus HTTPHdr::status_get (  )  [inline]
void HTTPHdr::status_set ( HTTPStatus  status  )  [inline]
HTTPType HTTPHdr::type_get (  )  const [inline]
int HTTPHdr::unmarshal ( char *  buf,
int  len,
RefCountObj block_ref 
)
URL * HTTPHdr::url_create ( URL url  )  [inline]
URL * HTTPHdr::url_get ( URL url  )  [inline]
URL * HTTPHdr::url_get (  )  const [inline]

Definition at line 1076 of file HTTP.h.

References HTTP_TYPE_REQUEST, ink_assert, m_http, HTTPHdrImpl::m_polarity, m_url_cached, URL::m_url_impl, mark_target_dirty(), HTTPHdrImpl::req, HdrHeapSDKHandle::set(), HTTPHdrImpl::u, and valid().

Referenced by _fill_target_cache(), HttpTransact::build_redirect_response(), HttpTransact::build_request(), HttpTransact::check_request_validity(), HttpTransactHeaders::convert_to_0_9_request_header(), HttpTransactHeaders::convert_to_1_0_request_header(), HttpTransactHeaders::convert_to_1_1_request_header(), HttpTransact::DecideCacheLookup(), RemapProcessor::finish_remap(), StatPagesManager::handle_http(), HttpTransact::handle_internal_request(), HttpTransact::handle_websocket_upgrade_pre_remap(), HttpTransact::HandleBlindTunnel(), PrefetchBlaster::handleCookieHeaders(), PrefetchBlaster::handleEvent(), host_get(), HttpPagesHandler::HttpPagesHandler(), PrefetchBlaster::init(), HttpTransact::initialize_state_variables_from_request(), HttpTransact::is_request_cache_lookupable(), HttpTransact::is_request_valid(), HttpTransact::merge_and_update_headers_for_cache_update(), HttpTransact::ModifyRequest(), path_get(), RemapProcessor::perform_remap(), PrefetchTransform::PrefetchTransform(), PrefetchTransform::redirect(), HttpSM::redirect_request(), register_ShowCache(), register_ShowCacheInternal(), register_ShowHostDB(), register_ShowNet(), UrlRewrite::Remap_redirect(), HttpTransactHeaders::remove_host_name_from_url(), HTTPInfo::request_url_get(), scheme_get(), HttpTransact::set_headers_for_cache_write(), RemapProcessor::setup_for_remap(), ShowCache::ShowCache(), HttpTransact::StartRemapRequest(), stat_callback(), HttpTransact::what_is_document_freshness(), and HttpTransact::will_this_request_self_loop().

int HTTPHdr::url_print ( char *  buff,
int  length,
int *  offset,
int *  skip 
)

Print the URL.

Output is not null terminated.

Returns:
0 on failure, non-zero on success.
Parameters:
buff Output buffer
length Length of buffer
[in,out] offset ???
[in,out] skip ???

Definition at line 1611 of file HTTP.cc.

References ink_release_assert, m_url_cached, and URL::print().

void HTTPHdr::url_set ( const char *  str,
int  length 
) [inline]
void HTTPHdr::url_set ( URL url  )  [inline]
void HTTPHdr::url_set_as_server_url ( URL url  )  [inline]
char * HTTPHdr::url_string_get ( Arena arena = 0,
int *  length = 0 
)

Get a string with the effective URL in it.

If length is not NULL then the length of the string is stored in the int pointed to by length.

Note that this can be different from getting the URL and invoking URL::string_get if the host is in a header field and not explicitly in the URL.

Parameters:
arena Arena to use, or malloc if NULL.
length Store string length here.

Definition at line 1592 of file HTTP.cc.

References m_url_cached, URL::string_get(), URL::string_get_ref(), and USE_HDR_HEAP_MAGIC.

Referenced by HttpTransact::build_error_response(), HttpRequestData::get_string(), HttpTransact::retry_server_connection_not_open(), and url_string_get_ref().

char * HTTPHdr::url_string_get_ref ( int *  length = 0  )  [inline]

Get a string with the effective URL in it.

This is automatically allocated if needed in the request heap.

See also:
url_string_get
Parameters:
length Store string length here.

Definition at line 1262 of file HTTP.h.

References url_string_get(), and USE_HDR_HEAP_MAGIC.

Referenced by LogAccessHttp::init().

int HTTPHdr::valid (  )  const [inline]

Reimplemented from MIMEHdr.

Definition at line 815 of file HTTP.h.

References HdrHeapSDKHandle::m_heap, m_http, and MIMEHdr::m_mime.

Referenced by HttpTransactHeaders::build_base_response(), HttpTransact::build_error_response(), copy(), HTTPCacheAlt::copy(), HttpTransactHeaders::copy_header_fields(), copy_shallow(), dump_hdr(), HttpSM::dump_state_hdr(), find_appropriate_cached_resp(), HttpTransact::handle_cache_operation_on_forward_server_response(), HttpTransact::handle_response_from_parent(), HttpTransact::handle_response_keep_alive_headers(), HttpTransact::handle_transform_ready(), HttpTransact::HandleApiErrorJump(), PrefetchBlaster::handleCookieHeaders(), HttpTransact::HandleICPLookup(), HttpTransact::HandleRequest(), LogAccessHttp::init(), is_cache_control_set(), is_pragma_no_cache_set(), length_get(), HTTPInfo::marshal(), HTTPInfo::marshal_length(), LogAccessHttp::marshal_proxy_resp_status_code(), method_get(), method_get_wksidx(), method_set(), parse_req(), parse_resp(), HttpTransact::PPDNSLookup(), PrefetchPlugin(), print(), reason_get(), reason_set(), PrefetchTransform::redirect(), HttpTransactCache::SelectFromAlternates(), ICPProcessor::start(), status_get(), status_set(), TSFetchPageRespGet(), TSHttpTxnCachedReqGet(), TSHttpTxnCachedRespGet(), TSHttpTxnCachedRespModifiableGet(), TSHttpTxnClientReqGet(), TSHttpTxnClientRespGet(), TSHttpTxnIsCacheable(), TSHttpTxnPristineUrlGet(), TSHttpTxnServerReqGet(), TSHttpTxnServerRespGet(), TSHttpTxnServerRespIgnore(), TSHttpTxnTransformRespGet(), TSHttpTxnUpdateCachedObject(), TSICPCachedReqGet(), TSICPCachedRespGet(), type_get(), url_create(), url_get(), url_set(), url_set_as_server_url(), version_get(), version_set(), and UpdateEntry::~UpdateEntry().

HTTPVersion HTTPHdr::version_get (  )  [inline]
void HTTPHdr::version_set ( HTTPVersion  version  )  [inline]

Friends And Related Function Documentation

friend class UrlPrintHack [friend]

Definition at line 682 of file HTTP.h.


Field Documentation

int HTTPHdr::m_host_length [mutable]

Length of hostname.

Definition at line 520 of file HTTP.h.

Referenced by _fill_target_cache(), host_get(), and set_url_target_from_host_field().

Definition at line 519 of file HTTP.h.

Referenced by _fill_target_cache(), host_get(), and set_url_target_from_host_field().

int HTTPHdr::m_port [mutable]

Target port.

Definition at line 521 of file HTTP.h.

Referenced by _fill_target_cache(), port_get(), and set_url_target_from_host_field().

bool HTTPHdr::m_port_in_header [mutable]

Set if the port was effectively specified in the header.

true if the target (in the URL or the HOST field) also specified a port. That is, true if whatever source had the target host also had a port, false otherwise.

Definition at line 528 of file HTTP.h.

Referenced by _fill_target_cache(), is_port_in_header(), and set_url_target_from_host_field().

bool HTTPHdr::m_target_cached [mutable]

Whether host name and port are cached.

Definition at line 522 of file HTTP.h.

Referenced by _fill_target_cache(), _test_and_fill_target_cache(), and mark_target_dirty().

bool HTTPHdr::m_target_in_url [mutable]

Whether host name and port are in the URL.

Definition at line 523 of file HTTP.h.

Referenced by _fill_target_cache(), host_get(), is_target_in_url(), and set_url_target_from_host_field().

Arena *const HTTPHdr::USE_HDR_HEAP_MAGIC = reinterpret_cast<Arena*>(1) [static, protected]

Definition at line 675 of file HTTP.h.

Referenced by url_string_get(), and url_string_get_ref().


The documentation for this class was generated from the following files: