NCBI C++ ToolKit
ncbicgi.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 #ifndef CGI___NCBICGI__HPP
2 #define CGI___NCBICGI__HPP
3 
4 /* $Id: ncbicgi.hpp 97194 2022-06-26 03:46:48Z lavr $
5 * ===========================================================================
6 *
7 * PUBLIC DOMAIN NOTICE
8 * National Center for Biotechnology Information
9 *
10 * This software/database is a "United States Government Work" under the
11 * terms of the United States Copyright Act. It was written as part of
12 * the author's official duties as a United States Government employee and
13 * thus cannot be copyrighted. This software/database is freely available
14 * to the public for use. The National Library of Medicine and the U.S.
15 * Government have not placed any restriction on its use or reproduction.
16 *
17 * Although all reasonable efforts have been taken to ensure the accuracy
18 * and reliability of the software and data, the NLM and the U.S.
19 * Government do not and cannot warrant the performance or results that
20 * may be obtained by using this software or data. The NLM and the U.S.
21 * Government disclaim all warranties, express or implied, including
22 * warranties of performance, merchantability or fitness for any particular
23 * purpose.
24 *
25 * Please cite the author in any work or product based on this material.
26 *
27 * ===========================================================================
28 *
29 * Author: Denis Vakatov
30 *
31 * File Description:
32 * NCBI C++ CGI API:
33 * CCgiCookie -- one CGI cookie
34 * CCgiCookies -- set of CGI cookies
35 * CCgiRequest -- full CGI request
36 */
37 
38 #include <corelib/rwstream.hpp>
39 #include <corelib/stream_utils.hpp>
40 #include <cgi/cgi_util.hpp>
41 #include <cgi/user_agent.hpp>
42 
43 
44 /** @addtogroup CGIReqRes
45  *
46  * @{
47  */
48 
49 
51 
52 
53 class CTime;
54 class CCgiSession;
56 
57 
58 ///////////////////////////////////////////////////////
59 ///
60 /// CCgiCookie::
61 ///
62 /// HTTP cookie class
63 ///
64 
65 
67 {
68 public:
69  /// Copy constructor
70  CCgiCookie(const CCgiCookie& cookie);
71 
72  /// Throw the "invalid_argument" if "name" or "value" have invalid format
73  /// - the "name" must not be empty; it must not contain '='
74  /// - "name", "value", "domain" -- must consist of printable ASCII
75  /// characters, and not: semicolons(;), commas(,), or space characters.
76  /// - "path" -- can have space characters.
77  CCgiCookie(const string& name, const string& value,
78  const string& domain = NcbiEmptyString,
79  const string& path = NcbiEmptyString);
80 
81  /// The cookie name cannot be changed during its whole timelife
82  const string& GetName(void) const;
83 
84  /// Whether the cookie is sent as a part of HTTP request or HTTP response
85  enum EWriteMethod {
87  eHTTPRequest
88  };
89 
90  /// Compose and write to output stream "os":
91  /// @param wmethod
92  /// - eHTTPResponse:
93  /// "Set-Cookie: name=value; expires=date; path=val_path; domain=dom_name;
94  /// secure\r\n"
95  /// Here, only "name=value" is mandatory, and other parts are optional
96  /// - eHTTPRequest:
97  /// "name=value"
98  /// Here, only "name=value" is printed, all other parts are ignored
100  EWriteMethod wmethod = eHTTPResponse,
101  EUrlEncode flag = eUrlEncode_SkipMarkChars) const;
102 
103  /// Reset everything but name to default state like CCgiCookie(m_Name, "")
104  void Reset(void);
105 
106  /// Set all attribute values(but name!) to those from "cookie"
107  void CopyAttributes(const CCgiCookie& cookie);
108 
109  /// All SetXXX(const string&) methods beneath:
110  /// - set the property to "str" if "str" has valid format
111  /// - throw the "invalid_argument" if "str" has invalid format
112  void SetValue (const string& str);
113  void SetDomain (const string& str); // not spec'd by default
114  void SetPath (const string& str); // not spec'd by default
115  void SetExpDate(const tm& exp_date); // GMT time (infinite if all zeros)
116  void SetExpTime(const CTime& exp_time);// GMT time (infinite if all zeros)
117  void SetSecure (bool secure); // FALSE by default
118  void SetHttpOnly(bool http_only); // FALSE by default
119 
120  /// All "const string& GetXXX(...)" methods beneath return reference
121  /// to "NcbiEmptyString" if the requested attributre is not set
122  const string& GetValue (void) const;
123  const string& GetDomain (void) const;
124  const string& GetPath (void) const;
125  /// Day, dd-Mon-yyyy hh:mm:ss GMT (return empty string if not set)
126  string GetExpDate(void) const;
127  /// If exp.date is not set then return FALSE and dont assign "*exp_date"
128  bool GetExpDate(tm* exp_date) const;
129  bool GetSecure(void) const;
130  bool GetHttpOnly(void) const;
131 
132  /// Compare two cookies
133  bool operator< (const CCgiCookie& cookie) const;
134 
135  /// Predicate for the cookie comparison
136  typedef const CCgiCookie* TCPtr;
137  struct PLessCPtr {
138  bool operator() (const TCPtr& c1, const TCPtr& c2) const {
139  return (*c1 < *c2);
140  }
141  };
142 
144  fValid = 0,
145  fInvalid_Name = 1<<0,
146  fInvalid_Value = 1<<1,
147  fInvalid_Any = fInvalid_Name | fInvalid_Value
148  };
149  typedef int TInvalidFlag;
150 
151  TInvalidFlag IsInvalid(void) const;
152  void SetInvalid(TInvalidFlag flag); // Set invalid flag bit
153  void ResetInvalid(TInvalidFlag flag); // Clear invalid flag bit
154 
155 private:
156  string m_Name;
157  string m_Value;
158  string m_Domain;
159  string m_Path;
160  tm m_Expires; // GMT time zone
161  bool m_Secure;
164 
165  enum EFieldType {
166  eField_Name, // Cookie name
167  eField_Value, // Cookie value
168  eField_Other // Other fields (domain etc.)
169  };
170  static void x_CheckField(const string& str,
171  EFieldType ftype,
172  const char* banned_symbols,
173  const string* cookie_name = NULL);
174  static string x_EncodeCookie(const string& str,
175  EFieldType ftype,
176  NStr::EUrlEncode flag);
177 
178  static bool x_GetString(string* str, const string& val);
179  // prohibit default assignment
180  CCgiCookie& operator= (const CCgiCookie&);
181  friend class CCgiCookies;
182 
183 public:
184  // Cookie encoding style - CParam needs this to be public
186  eCookieEnc_Url, // use URL encode/decode
187  eCookieEnc_Quote // use quoting (don't encode names)
188  };
189 }; // CCgiCookie
190 
191 
192 /* @} */
193 
194 
195 inline CNcbiOstream& operator<< (CNcbiOstream& os, const CCgiCookie& cookie)
196 {
197  return cookie.Write(os);
198 }
199 
200 
201 /** @addtogroup CGIReqRes
202  *
203  * @{
204  */
205 
206 
207 ///////////////////////////////////////////////////////
208 ///
209 /// CCgiCookies::
210 ///
211 /// Set of CGI send-cookies
212 ///
213 /// The cookie is uniquely identified by {name, domain, path}.
214 /// "name" is mandatory and non-empty; "domain" and "path" are optional.
215 /// "name" and "domain" are not case-sensitive; "path" is case-sensitive.
216 ///
217 
219 {
220 public:
224  typedef pair<TIter, TIter> TRange;
225  typedef pair<TCIter, TCIter> TCRange;
226 
227  /// How to handle badly formed cookies
229  eOnBadCookie_ThrowException, ///< Throw exception, ignore bad cookie
230  eOnBadCookie_SkipAndError, ///< Report error, ignore bad cookie
231  eOnBadCookie_Skip, ///< Silently ignore bad cookie
232  eOnBadCookie_StoreAndError, ///< Report error, store bad cookie as-is
233  eOnBadCookie_Store ///< Store bad cookie without URL-decoding
234  };
235 
236  /// Empty set of cookies
237  CCgiCookies(void);
238  /// Use the specified method of string encoding
239  CCgiCookies(EUrlEncode encode_flag);
240  /// Format of the string: "name1=value1; name2=value2; ..."
241  CCgiCookies(const string& str,
242  EOnBadCookie on_bad_cookie = eOnBadCookie_SkipAndError,
243  EUrlEncode encode_flag = eUrlEncode_SkipMarkChars);
244  /// Destructor
245  ~CCgiCookies(void);
246 
247  /// Return TRUE if this set contains no cookies
248  bool Empty(void) const;
249 
250  EUrlEncode GetUrlEncodeFlag(void) const;
251  void SetUrlEncodeFlag(EUrlEncode encode_flag);
252 
253  /// All Add() functions:
254  /// if the added cookie has the same {name, domain, path} as an already
255  /// existing one then the new cookie will override the old one
256  CCgiCookie* Add(const string& name,
257  const string& value,
258  const string& domain = kEmptyStr,
259  const string& path = kEmptyStr,
260  EOnBadCookie on_bad_cookie = eOnBadCookie_SkipAndError);
261 
262  ///
263  CCgiCookie* Add(const string& name,
264  const string& value,
265  EOnBadCookie on_bad_cookie);
266 
267  /// Update with a copy of "cookie"
268  CCgiCookie* Add(const CCgiCookie& cookie);
269 
270  /// Update by a set of cookies
271  void Add(const CCgiCookies& cookies);
272 
273  /// Update with a HTTP request like string:
274  /// "name1=value1; name2=value2; ..."
275  void Add(const string& str,
276  EOnBadCookie on_bad_cookie = eOnBadCookie_SkipAndError);
277 
278  /// Return NULL if cannot find this exact cookie
279  CCgiCookie* Find(const string& name,
280  const string& domain, const string& path);
281  const CCgiCookie* Find(const string& name,
282  const string& domain, const string& path) const;
283 
284  /// Return the first matched cookie with name "name", or NULL if
285  /// there is no such cookie(s).
286  /// Also, if "range" is non-NULL then assign its "first" and
287  /// "second" fields to the beginning and the end of the range
288  /// of cookies matching the name "name".
289  /// NOTE: if there is a cookie with empty domain and path then
290  /// this cookie is guaranteed to be returned.
291  CCgiCookie* Find(const string& name, TRange* range=0);
292  const CCgiCookie* Find(const string& name, TCRange* range=0) const;
293 
294  /// Return the full range [begin():end()] on the underlying container
295  TCRange GetAll(void) const;
296 
297  /// Remove "cookie" from this set; deallocate it if "destroy" is true
298  /// Return FALSE if can not find "cookie" in this set
299  bool Remove(CCgiCookie* cookie, bool destroy=true);
300 
301  /// Remove (and destroy if "destroy" is true) all cookies belonging
302  /// to range "range". Return # of found and removed cookies.
303  size_t Remove(TRange& range, bool destroy=true);
304 
305  /// Remove (and destroy if "destroy" is true) all cookies with the
306  /// given "name". Return # of found and removed cookies.
307  size_t Remove(const string& name, bool destroy=true);
308 
309  /// Remove all stored cookies
310  void Clear(void);
311 
312  /// Printout all cookies into the stream "os"
313  /// @sa CCgiCookie::Write
315  CCgiCookie::EWriteMethod wmethod
316  = CCgiCookie::eHTTPResponse) const;
317 
318  /// Set secure connection flag. Affects printing of cookies:
319  /// secure cookies can be sent only trough secure connections.
320  void SetSecure(bool secure) { m_Secure = secure; }
321 
322  /// Mark all cookies as secure.
323  void SetAllCookiesSecure(bool value);
324  bool GetAllCookiesSecure(void) const { return m_AllSecure; }
325 
326  /// Mark all cookies as HTTP_ONLY.
327  void SetAllCookiesHttpOnly(bool value);
328  bool GetAllCookiesHttpOnly(void) const { return m_AllHttpOnly; }
329 
330 private:
332  eCheck_Valid, // Cookie is valid
333  eCheck_SkipInvalid, // Cookie is invalid and should be ignored
334  eCheck_StoreInvalid // Cookie is invalid but should be stored
335  };
336  static ECheckResult x_CheckField(const string& str,
338  const char* banned_symbols,
339  EOnBadCookie on_bad_cookie,
340  const string* cookie_name = NULL);
341 
344  bool m_Secure;
347 
348  /// prohibit default initialization and assignment
350  CCgiCookies& operator= (const CCgiCookies&);
351 };
352 
353 
354 /// Parameter to control error handling of incoming cookies.
355 /// Does not affect error handling of outgoing cookies set by the
356 /// application.
360 
361 /* @} */
362 
363 
364 inline CNcbiOstream& operator<< (CNcbiOstream& os, const CCgiCookies& cookies)
365 {
366  return cookies.Write(os);
367 }
368 
369 
370 /** @addtogroup CGIReqRes
371  *
372  * @{
373  */
374 
375 
376 /// Set of "standard" HTTP request properties
377 /// @sa CCgiRequest
378 enum ECgiProp {
379  // server properties
384  eCgi_ServerPort, // see also "GetServerPort()"
385 
386  // client properties
388  eCgi_RemoteAddr, // see also "GetRemoteAddr()"
389 
390  // client data properties
392  eCgi_ContentLength, // see also "GetContentLength()"
393 
394  // request properties
400 
401  // authentication info
405 
406  // semi-standard properties(from HTTP header)
412 
413  // # of CCgiRequest-supported standard properties
414  // for internal use only!
416 }; // ECgiProp
417 
418 
419 /// @sa CCgiRequest
420 class NCBI_XCGI_EXPORT CCgiEntry // copy-on-write semantics
421 {
422 private:
423  struct SData : public CObject
424  {
425  SData(const string& value, const string& filename,
426  unsigned int position, const string& type)
427  : m_Value(value), m_Filename(filename), m_ContentType(type),
428  m_Position(position) { }
429  SData(const SData& data)
430  : CObject(),
431  m_Value(data.m_Value), m_Filename(data.m_Filename),
432  m_ContentType(data.m_ContentType),
433  m_Position(data.m_Position)
434  { _ASSERT( !data.m_Reader.get() ); }
435 
436  string m_Value, m_Filename, m_ContentType;
437  unsigned int m_Position;
438  unique_ptr<IReader> m_Reader;
439  };
440 
441 public:
442  CCgiEntry(const string& value = kEmptyStr,
443  // default empty value for 1 constructor only
444  const string& filename = kEmptyStr,
445  unsigned int position = 0,
446  const string& type = kEmptyStr)
447  : m_Data(new SData(value, filename, position, type)) { }
448  CCgiEntry(const char* value,
449  const string& filename = kEmptyStr,
450  unsigned int position = 0,
451  const string& type = kEmptyStr)
452  : m_Data(new SData(value, filename, position, type)) { }
454  : m_Data(e.m_Data) { }
455 
457  {
458  SetValue(e.GetValue());
459  SetFilename(e.GetFilename());
460  SetContentType(e.GetContentType());
461  SetPosition(e.GetPosition());
462  return *this;
463  }
464 
465 
466  /// Get the value as a string, (necessarily) prefetching it all if
467  /// applicable; the result remains available for future calls to
468  /// GetValue and relatives.
469  /// @sa GetValueReader, GetValueStream
470  const string& GetValue() const
471  {
472  if (m_Data->m_Reader.get()) { x_ForceComplete(); }
473  return m_Data->m_Value;
474  }
475  string& SetValue()
476  { x_ForceUnique(); return m_Data->m_Value; }
477  void SetValue(const string& v)
478  { x_ForceUnique(); m_Data->m_Value = v; }
480  { x_ForceUnique(); m_Data->m_Reader.reset(r); }
482  { x_ForceUnique(); m_Data->m_Reader.reset(new CStreamReader(is, own)); }
483 
484  /// Get the value via a reader, potentially on the fly -- in which
485  /// case the caller takes ownership of the source, and subsequent
486  /// calls to GetValue and relatives will yield NO data. (In
487  /// either case, the caller owns the resulting object.)
488  /// @sa GetValue, GetValueStream
489  IReader* GetValueReader();
490 
491  /// Get the value as a stream, potentially on the fly -- in which
492  /// case the caller takes ownership of the source, and subsequent
493  /// calls to GetValue and relatives will yield NO data. (In
494  /// either case, the caller owns the resulting object.)
495  /// @sa GetValue, GetValueReader
496  CNcbiIstream* GetValueStream();
497 
498  /// Action to perform if the explicit charset is not supported
500  eCharsetError_Ignore, ///< Ignore unknown charset (try to autodetect)
501  eCharsetError_Throw ///< Throw exception if charset is not supported
502  };
503 
504  CStringUTF8 GetValueAsUTF8(EOnCharsetError on_error =
505  eCharsetError_Ignore) const;
506 
507  /// Only available for certain fields of POSTed forms
508  const string& GetFilename() const
509  { return m_Data->m_Filename; }
510  string& SetFilename()
511  { x_ForceUnique(); return m_Data->m_Filename; }
512  void SetFilename(const string& f)
513  { x_ForceUnique(); m_Data->m_Filename = f; }
514 
515  /// CGI parameter number -- automatic image name parameter is #0,
516  /// explicit parameters start at #1
517  unsigned int GetPosition() const
518  { return m_Data->m_Position; }
519  unsigned int& SetPosition()
520  { x_ForceUnique(); return m_Data->m_Position; }
521  void SetPosition(int p)
522  { x_ForceUnique(); m_Data->m_Position = p; }
523 
524  /// May be available for some fields of POSTed forms
525  const string& GetContentType() const
526  { return m_Data->m_ContentType; }
527  string& SetContentType()
528  { x_ForceUnique(); return m_Data->m_ContentType; }
529  void SetContentType(const string& f)
530  { x_ForceUnique(); m_Data->m_ContentType = f; }
531 
532  operator const string&() const { return GetValue(); }
533  operator string&() { return SetValue(); }
534  operator const CTempStringEx() const { return CTempStringEx(GetValue()); }
535 
536  /// commonly-requested string:: operations...
537  SIZE_TYPE size() const { return GetValue().size(); }
538  bool empty() const { return GetValue().empty(); }
539  const char* c_str() const { return GetValue().c_str(); }
540  int compare(const string& s) const { return GetValue().compare(s); }
541  int compare(const char* s) const { return GetValue().compare(s); }
542  string substr(SIZE_TYPE i = 0, SIZE_TYPE n = NPOS) const
543  { return GetValue().substr(i, n); }
544  SIZE_TYPE find(const char* s, SIZE_TYPE pos = 0) const
545  { return GetValue().find(s, pos); }
546  SIZE_TYPE find(const string& s, SIZE_TYPE pos = 0) const
547  { return GetValue().find(s, pos); }
548  SIZE_TYPE find(char c, SIZE_TYPE pos = 0) const
549  { return GetValue().find(c, pos); }
550  SIZE_TYPE find_first_of(const string& s, SIZE_TYPE pos = 0) const
551  { return GetValue().find_first_of(s, pos); }
552  SIZE_TYPE find_first_of(const char* s, SIZE_TYPE pos = 0) const
553  { return GetValue().find_first_of(s, pos); }
554 
555 
556  bool operator ==(const CCgiEntry& e2) const
557  {
558  // conservative; some may be irrelevant in many cases
559  return (GetValue() == e2.GetValue()
560  && GetFilename() == e2.GetFilename()
561  // && GetPosition() == e2.GetPosition()
562  && GetContentType() == e2.GetContentType());
563  }
564 
565  bool operator !=(const CCgiEntry& v) const
566  {
567  return !(*this == v);
568  }
569 
570  bool operator ==(const string& v) const
571  {
572  return GetValue() == v;
573  }
574 
575  bool operator !=(const string& v) const
576  {
577  return !(*this == v);
578  }
579 
580  bool operator ==(const char* v) const
581  {
582  return GetValue() == v;
583  }
584 
585  bool operator !=(const char* v) const
586  {
587  return !(*this == v);
588  }
589 
590 private:
592  {
593  if ( !m_Data->ReferencedOnlyOnce() ) {
594  if (m_Data->m_Reader.get()) { x_ForceComplete(); }
595  m_Data = new SData(*m_Data);
596  }
597  }
598 
599  void x_ForceComplete() const;
600 
601  // Get charset from content type or empty string
602  string x_GetCharset(void) const;
603 
605 };
606 
607 
608 /* @} */
609 
610 inline
611 string operator +(const CCgiEntry& e, const string& s)
612 {
613  return e.GetValue() + s;
614 }
615 
616 inline
617 string operator +(const string& s, const CCgiEntry& e)
618 {
619  return s + e.GetValue();
620 }
621 
622 inline
624 {
625  return o << e.GetValue();
626  // filename omitted in case anything depends on just getting the value
627 }
628 
629 
630 /** @addtogroup CGIReqRes
631  *
632  * @{
633  */
634 
635 
636 // Typedefs
641 typedef list<string> TCgiIndexes;
642 
643 // Forward class declarations
644 class CNcbiArguments;
645 class CNcbiEnvironment;
646 class CTrackingEnvHolder;
647 
648 
649 // Base helper class for building query string from request arguments.
651 public:
652  virtual ~CEntryCollector_Base(void) {}
653  virtual void AddEntry(const string& name,
654  const string& value,
655  const string& filename,
656  bool is_index = false) = 0;
657 };
658 
659 
661 public:
663  ~CExtraEntryCollector(void) override {}
664 
665  void AddEntry(const string& name,
666  const string& value,
667  const string& filename,
668  bool is_index) override;
669 
670  CDiagContext_Extra::TExtraArgs& GetArgs(void) { return m_Args; }
671 
672 private:
674 };
675 
676 
677 ///////////////////////////////////////////////////////
678 ///
679 /// CCgiRequest::
680 ///
681 /// The CGI request class
682 ///
683 
685 {
686 public:
687  /// Startup initialization
688  ///
689  /// - retrieve request's properties and cookies from environment;
690  /// - retrieve request's entries from "$QUERY_STRING".
691  ///
692  /// If "$REQUEST_METHOD" == "POST" and "$CONTENT_TYPE" is empty or either
693  /// "application/x-www-form-urlencoded" or "multipart/form-data",
694  /// and "fDoNotParseContent" flag is not set,
695  /// then retrieve and parse entries from the input stream "istr".
696  /// If "$CONTENT_TYPE" is empty, the contents is not stripped from
697  /// the stream but remains available (pushed back) whether or not
698  /// the form parsing was successful.
699  ///
700  /// If "$REQUEST_METHOD" is undefined then try to retrieve the request's
701  /// entries from the 1st cmd.-line argument, and do not use "$QUERY_STRING"
702  /// and "istr" at all.
703  typedef int TFlags;
704  enum Flags {
705  /// do not handle indexes as regular FORM entries with empty value
706  fIndexesNotEntries = (1 << 0),
707  /// do not parse $QUERY_STRING (or cmd.line if $REQUEST_METHOD not def)
708  fIgnoreQueryString = (1 << 1),
709  /// own the passed "env" (and destroy it in the destructor)
710  fOwnEnvironment = (1 << 2),
711  /// do not automatically parse the request's content body (from "istr")
712  fDoNotParseContent = (1 << 3),
713  /// use case insensitive CGI arguments
714  fCaseInsensitiveArgs = (1 << 4),
715  /// Do not use URL-encoding/decoding for cookies
716  fCookies_Unencoded = (1 << 5),
717  /// Use hex code for encoding spaces rather than '+'
718  fCookies_SpaceAsHex = (1 << 6),
719  /// Save request content (available through GetContent())
720  fSaveRequestContent = (1 << 7),
721  /// Do not check if page hit id is present, do not generate one
722  /// if it's missing.
723  fIgnorePageHitId = (1 << 8),
724  /// Set client-ip and session-id properties for logging.
725  fSkipDiagProperties = (1 << 9),
726  /// Old (deprecated) flag controlling diag properties.
727  fSetDiagProperties = 0,
728  /// Enable on-demand parsing via GetNextEntry()
729  fParseInputOnDemand = (1 << 10),
730  /// Do not treat semicolon as query string argument separator
731  fSemicolonIsNotArgDelimiter = (1 << 11),
732  /// Do not set outgoing tracking cookie. This can also be
733  /// done per-request using CCgiResponce::DisableTrackingCookie().
734  fDisableTrackingCookie = (1 << 12),
735  /// When parsing input on demand iterate all existing entries (e.g. those
736  /// read from QUERY_STRING) before parsing POST data.
737  /// @sa fParseInputOnDemand
738  fIncludePreparsedEntries = (1 << 13),
739  /// Disable parsing input as 'indexed' query (RFC3875) even if no '=' is present
740  fDisableParsingAsIndex = (1 << 14),
741  };
742  CCgiRequest(const CNcbiArguments* args = 0,
743  const CNcbiEnvironment* env = 0,
744  CNcbiIstream* istr = 0 /*NcbiCin*/,
745  TFlags flags = 0,
746  int ifd = -1,
747  size_t errbuf_size = 256);
748  /// args := CNcbiArguments(argc,argv), env := CNcbiEnvironment(envp)
749  CCgiRequest(int argc,
750  const char* const* argv,
751  const char* const* envp = 0,
752  CNcbiIstream* istr = 0,
753  TFlags flags = 0,
754  int ifd = -1,
755  size_t errbuf_size = 256);
757  TFlags flags = 0,
758  size_t errbuf_size = 256);
759 
760  /// Destructor
761  ~CCgiRequest(void);
762 
763  /// Get name (not value!) of a "standard" property
764  static const string GetPropertyName(ECgiProp prop);
765 
766  /// Get value of a "standard" property (return empty string if not defined)
767  const string& GetProperty(ECgiProp prop) const;
768 
769  /// Get value of a random client property; if "http" is TRUE then add
770  /// prefix "HTTP_" to the property name.
771  //
772  /// NOTE: usually, the value is extracted from the environment variable
773  /// named "$[HTTP]_<key>". Be advised, however, that in the case of
774  /// FastCGI application, the set (and values) of env.variables change
775  /// from request to request, and they differ from those returned
776  /// by CNcbiApplication::GetEnvironment()!
777  const string& GetRandomProperty(const string& key, bool http = true) const;
778 
779  /// Get content length using value of the property 'eCgi_ContentLength'.
780  /// Return "kContentLengthUnknown" if Content-Length header is missing.
781  static const size_t kContentLengthUnknown;
782  size_t GetContentLength(void) const;
783 
784  /// Get request content. The content is saved only when fSaveRequestContent
785  /// flag is set. Otherwise the method will throw an exception.
786  const string& GetContent(void) const;
787 
788  /// Retrieve the request cookies
789  const CCgiCookies& GetCookies(void) const;
790  CCgiCookies& GetCookies(void);
791 
792  /// Get a set of entries(decoded) received from the client.
793  /// Also includes "indexes" if "indexes_as_entries" in the
794  /// constructor was TRUE (default).
795  /// NOTE: In the "fParseInputOnDemand" mode not all of the entries
796  /// may be loaded at the time of the call.
797  const TCgiEntries& GetEntries(void) const;
798  TCgiEntries& GetEntries(void);
799 
800  /// Get entry value by name
801  ///
802  /// NOTE 1: There can be more than one entry with the same name;
803  /// only one of these entry will be returned. To get all matches
804  /// use GetEntries() and "multimap::" member functions.
805  /// NOTE 2: In the "fParseInputOnDemand" mode not all of the entries
806  /// may be loaded at the time of the call, so -- use
807  /// GetPossiblyUnparsedEntry() instead.
808  const CCgiEntry& GetEntry(const string& name, bool* is_found = 0) const;
809 
810  /// Get next entry when parsing input on demand.
811  ///
812  /// Returns GetEntries().end() when all entries have been parsed.
813  TCgiEntriesI GetNextEntry(void);
814 
815  /// Get entry value by name, calling GetNextEntry() as needed.
816  ///
817  /// NOTE: There can be more than one entry with the same name;
818  /// only one of these entry will be returned.
819  ///
820  /// To get all matches, use GetEntries() and "multimap::" member
821  /// functions. If there is no such entry, this method will parse
822  /// (and save) any remaining input and return NULL.
823  CCgiEntry* GetPossiblyUnparsedEntry(const string& name);
824 
825  /// Parse any remaining POST content for use by GetEntries() et al.
826  void ParseRemainingContent(void);
827 
828  /// Get a set of indexes(decoded) received from the client.
829  ///
830  /// It will always be empty if "indexes_as_entries" in the constructor
831  /// was TRUE (default).
832  const TCgiIndexes& GetIndexes(void) const;
833  TCgiIndexes& GetIndexes(void);
834 
836  /// If Session does not exist the new one will be created
838  /// If Session does not exist the exception will be thrown
839  eDontCreateIfNotExist,
840  ///< Do not try to load or create session
841  eDontLoad
842  };
843 
844  /// Get session
845  ///
846  CCgiSession& GetSession(ESessionCreateMode mode = eCreateIfNotExist) const;
847 
848  /// Return pointer to the input stream.
849  ///
850  /// Return NULL if the input stream is absent, or if it has been
851  /// automagically read and parsed already (the "POST" method, and
852  /// "application/x-www-form-urlencoded" or "multipart/form-data" type,
853  /// and "fDoNotParseContent" flag was not passed to the constructor).
854  CNcbiIstream* GetInputStream(void) const;
855  /// Returns file descriptor of input stream, or -1 if unavailable.
856  int GetInputFD(void) const;
857 
858  /// Set input stream to "is".
859  ///
860  /// If "own" is set to TRUE then this stream will be destroyed
861  /// as soon as SetInputStream() gets called with another stream pointer.
862  /// NOTE: SetInputStream(0) will be called in ::~CCgiRequest().
863  void SetInputStream(CNcbiIstream* is, bool own = false, int fd = -1);
864 
865  /// Decode the URL-encoded(FORM or ISINDEX) string "str" into a set of
866  /// entries <"name", "value"> and add them to the "entries" set.
867  ///
868  /// The new entries are added without overriding the original ones, even
869  /// if they have the same names.
870  /// FORM format: "name1=value1&.....", ('=' and 'value' are optional)
871  /// ISINDEX format: "val1+val2+val3+....."
872  /// If the "str" is in ISINDEX format then the entry "value" will be empty.
873  /// On success, return zero; otherwise return location(1-based) of error
874  static SIZE_TYPE ParseEntries(const string& str, TCgiEntries& entries);
875 
876  /// Decode the URL-encoded string "str" into a set of ISINDEX-like entries
877  /// and add them to the "indexes" set.
878  /// @return
879  /// zero on success; otherwise, 1-based location of error
880  static SIZE_TYPE ParseIndexes(const string& str, TCgiIndexes& indexes);
881 
882  /// Return client tracking environment variables
883  /// These variables are stored in the form "name=value".
884  /// The last element in the returned array is 0.
885  const char* const* GetClientTrackingEnv(void) const;
886 
887  /// Serialize/Deserialize a request to/from a stream
888  void Serialize(CNcbiOstream& os) const;
889  void Deserialize(CNcbiIstream& is, TFlags flags = 0);
890 
891  const CNcbiEnvironment& GetEnvironment() const { return *m_Env; }
892 
893  /// Get full set of arguments (both GET and POST), URL-encoded.
894  /// A &-separated list of exclusions can be set in CGI_LOG_EXCLUDE_ARGS
895  /// variable or [CGI] LOG_EXCLUDE_ARGS value in ini file.
896  void GetCGIEntries(CEntryCollector_Base& collector) const;
897 
898  /// Shortcut for collecting arguments into a URL-style string.
899  /// @sa GetCGIEntries
900  string GetCGIEntriesStr(void) const;
901 
902  bool CalcChecksum(string& checksum, string& content) const;
903 
904  /// Standard request methods.
914  eMethod_Other ///< Unknown method, use GetRequestMethodName to read.
915  };
916 
917  /// Get request method name.
918  const string& GetRequestMethodName(void) const;
919  /// Get request method.
920  ERequestMethod GetRequestMethod(void) const;
921 
922  /// Store/retrieve tracking cookie value.
923  /// Unlike CCgiResponse or CRequestContext, this value is not empty only
924  /// if the tracking ID was actually received in the request.
925  void SetTrackingCookie(const string& cookie_value) { m_TrackingCookie = cookie_value; }
926  const string& GetTrackingCookie(void) const { return m_TrackingCookie; }
927 
928 private:
929  /// set of environment variables
931  unique_ptr<CNcbiEnvironment> m_OwnEnv;
932  /// Original request content or NULL if fSaveRequestContent is not set
933  unique_ptr<string> m_Content;
934  /// set of the request FORM-like entries(already retrieved; cached)
936  /// set of the request ISINDEX-like indexes(already retrieved; cached)
938  /// set of the request cookies(already retrieved; cached)
940  /// input stream
942  /// input file descriptor, if available.
945  /// Request initialization error buffer size;
946  /// when initialization code hits unexpected EOF it will try to
947  /// add diagnostics and print out accumulated request buffer
948  /// 0 in this variable means no buffer diagnostics
949  size_t m_ErrBufSize;
951 
953  /// the real constructor code
954  void x_Init(const CNcbiArguments* args,
955  const CNcbiEnvironment* env,
956  CNcbiIstream* istr,
957  TFlags flags,
958  int ifd);
959 
960  /// retrieve(and cache) a property of given name
961  const string& x_GetPropertyByName(const string& name) const;
962  /// Parse entries or indexes from "$QUERY_STRING" or cmd.-line args
963  void x_ProcessQueryString(TFlags flags, const CNcbiArguments* args);
964  /// Parse input stream if needed
965  void x_ProcessInputStream(TFlags flags, CNcbiIstream* istr, int ifd);
966 
967  /// Set client-ip property for logging
968  void x_SetClientIpProperty(TFlags flags) const;
969 
970  /// Set the properties of CRequestContext (HitId, Dtab etc.).
971  void x_InitRequestContext(TFlags flags);
972 
973  /// prohibit default initialization and assignment
975  CCgiRequest& operator= (const CCgiRequest&);
976 
977  string x_RetrieveSessionId() const;
978 
979  mutable unique_ptr<CTrackingEnvHolder> m_TrackingEnvHolder;
982 
983 public:
984  void x_SetSession(CCgiSession& session);
985 
986 }; // CCgiRequest
987 
988 
989 /* @} */
990 
991 
992 /////////////////////////////////////////////////////////////////////////////
993 
994 /////////////////////////////////////////////////////////////////////////////
995 // IMPLEMENTATION of INLINE functions
996 /////////////////////////////////////////////////////////////////////////////
997 
998 
999 
1000 ///////////////////////////////////////////////////////
1001 // CCgiCookie::
1002 //
1003 
1004 
1005 // CCgiCookie::SetXXX()
1006 
1007 inline void CCgiCookie::SetValue(const string& str) {
1008  m_Value = str;
1010 }
1011 inline void CCgiCookie::SetDomain(const string& str) {
1012  x_CheckField(str, eField_Other, " ;", &m_Name);
1013  m_Domain = str;
1014 }
1015 inline void CCgiCookie::SetPath(const string& str) {
1016  x_CheckField(str, eField_Other, ";,", &m_Name);
1017  m_Path = str;
1018 }
1019 inline void CCgiCookie::SetExpDate(const tm& exp_date) {
1020  m_Expires = exp_date;
1021 }
1022 inline void CCgiCookie::SetSecure(bool secure) {
1023  m_Secure = secure;
1024 }
1025 inline void CCgiCookie::SetHttpOnly(bool http_only) {
1026  m_HttpOnly = http_only;
1027 }
1028 
1029 // CCgiCookie::GetXXX()
1030 
1031 inline const string& CCgiCookie::GetName(void) const {
1032  return m_Name;
1033 }
1034 inline const string& CCgiCookie::GetValue(void) const {
1035  return m_Value;
1036 }
1037 inline const string& CCgiCookie::GetDomain(void) const {
1038  return m_Domain;
1039 }
1040 inline const string& CCgiCookie::GetPath(void) const {
1041  return m_Path;
1042 }
1043 inline bool CCgiCookie::GetSecure(void) const {
1044  return m_Secure;
1045 }
1046 inline bool CCgiCookie::GetHttpOnly(void) const {
1047  return m_HttpOnly;
1048 }
1049 
1051 {
1052  return m_InvalidFlag;
1053 }
1055 {
1056  m_InvalidFlag |= flag;
1057 }
1059 {
1060  m_InvalidFlag &= ~flag;
1061 }
1062 
1063 
1064 ///////////////////////////////////////////////////////
1065 // CCgiCookies::
1066 //
1067 
1069  : m_EncodeFlag(NStr::eUrlEnc_SkipMarkChars),
1070  m_Cookies(),
1071  m_Secure(false),
1072  m_AllSecure(false),
1073  m_AllHttpOnly(false)
1074 {
1075  return;
1076 }
1077 
1079  : m_EncodeFlag(NStr::EUrlEncode(encode_flag)),
1080  m_Cookies(),
1081  m_Secure(false),
1082  m_AllSecure(false),
1083  m_AllHttpOnly(false)
1084 {
1085  return;
1086 }
1087 
1088 inline CCgiCookies::CCgiCookies(const string& str,
1089  EOnBadCookie on_bad_cookie,
1090  EUrlEncode encode_flag)
1091  : m_EncodeFlag(NStr::EUrlEncode(encode_flag)),
1092  m_Cookies(),
1093  m_Secure(false),
1094  m_AllSecure(false),
1095  m_AllHttpOnly(false)
1096 {
1097  Add(str, on_bad_cookie);
1098 }
1099 
1100 inline
1102 {
1103  return EUrlEncode(m_EncodeFlag);
1104 }
1105 
1106 inline
1108 {
1109  m_EncodeFlag = NStr::EUrlEncode(encode_flag);
1110 }
1111 
1112 inline bool CCgiCookies::Empty(void) const
1113 {
1114  return m_Cookies.empty();
1115 }
1116 
1117 inline size_t CCgiCookies::Remove(const string& name, bool destroy)
1118 {
1119  TRange range;
1120  return Find(name, &range) ? Remove(range, destroy) : 0;
1121 }
1122 
1124 {
1125  Clear();
1126 }
1127 
1128 
1129 
1130 ///////////////////////////////////////////////////////
1131 // CCgiEntry::
1132 //
1133 
1134 
1135 inline
1137 {
1138  if (m_Data->m_Reader.get()) {
1139  return m_Data->m_Reader.release();
1140  } else {
1141  return new CStringReader(m_Data->m_Value);
1142  }
1143 }
1144 
1145 
1146 inline
1148 {
1149  if (m_Data->m_Reader.get()) {
1150  return new CRStream(m_Data->m_Reader.release(), 0, 0,
1152  } else {
1153  return new CNcbiIstrstream(GetValue());
1154  }
1155 }
1156 
1157 
1158 inline
1160 {
1161  _ASSERT(m_Data->m_Reader.get());
1162  _ASSERT(m_Data->m_Value.empty());
1163  SData& data = const_cast<SData&>(*m_Data);
1164  unique_ptr<IReader> reader(data.m_Reader.release());
1165  g_ExtractReaderContents(*reader, data.m_Value);
1166 }
1167 
1168 
1169 ///////////////////////////////////////////////////////
1170 // CCgiRequest::
1171 //
1172 
1173 inline const CCgiCookies& CCgiRequest::GetCookies(void) const {
1174  return m_Cookies;
1175 }
1177  return m_Cookies;
1178 }
1179 
1180 
1181 inline const TCgiEntries& CCgiRequest::GetEntries(void) const {
1182  return m_Entries;
1183 }
1185  return m_Entries;
1186 }
1187 
1188 
1190  return m_Indexes;
1191 }
1192 inline const TCgiIndexes& CCgiRequest::GetIndexes(void) const {
1193  return m_Indexes;
1194 }
1195 
1197  return m_Input;
1198 }
1199 
1200 inline int CCgiRequest::GetInputFD(void) const {
1201  return m_InputFD;
1202 }
1203 
1205 {
1206  m_Session = &session;
1207 }
1208 
1210 
1211 #endif /* CGI___NCBICGI__HPP */
bool operator!=(const _Ht_iterator< _Val, _Nonconst_traits< _Val >, _Key, _HF, _ExK, _EqK, _All > &__x, const _Ht_iterator< _Val, _Const_traits< _Val >, _Key, _HF, _ExK, _EqK, _All > &__y)
Definition: _hashtable.h:173
CCgiCookie::
Definition: ncbicgi.hpp:67
CCgiCookies::
Definition: ncbicgi.hpp:219
CCgiRequest::
Definition: ncbicgi.hpp:685
CCgiSession –.
Definition: cgi_session.hpp:62
CNcbiArguments –.
Definition: ncbienv.hpp:236
CNcbiEnvironment –.
Definition: ncbienv.hpp:110
CObject –.
Definition: ncbiobj.hpp:180
Note about the "buf_size" parameter for streams in this API.
Definition: rwstream.hpp:122
@ fOwnReader
Own the underlying reader.
Definition: rwstreambuf.hpp:66
CRef –.
Definition: ncbiobj.hpp:618
istream-based IReader
string-based IReader
CTime –.
Definition: ncbitime.hpp:296
A very basic data-read interface.
NStr –.
Definition: ncbistr.hpp:243
parent_type::iterator iterator
Definition: set.hpp:80
bool empty() const
Definition: set.hpp:133
parent_type::const_iterator const_iterator
Definition: set.hpp:79
static uch flags
bool operator<(const CEquivRange &A, const CEquivRange &B)
bool operator==(const CEquivRange &A, const CEquivRange &B)
bool Empty(const CNcbiOstrstream &src)
Definition: fileutil.cpp:523
#define false
Definition: bool.h:36
static const char * str(char *buf, int n)
Definition: stats.c:84
static HENV env
Definition: transaction2.c:38
static FILE * f
Definition: readconf.c:23
char data[12]
Definition: iconv.c:80
@ eNoOwnership
No ownership is assumed.
Definition: ncbi_types.h:135
set< CCgiCookie *, CCgiCookie::PLessCPtr > TSet
Definition: ncbicgi.hpp:221
SIZE_TYPE find(char c, SIZE_TYPE pos=0) const
Definition: ncbicgi.hpp:548
bool m_AllSecure
Definition: ncbicgi.hpp:345
void SetFilename(const string &f)
Definition: ncbicgi.hpp:512
SIZE_TYPE find(const string &s, SIZE_TYPE pos=0) const
Definition: ncbicgi.hpp:546
int GetInputFD(void) const
Returns file descriptor of input stream, or -1 if unavailable.
Definition: ncbicgi.hpp:1200
const CNcbiEnvironment * m_Env
set of environment variables
Definition: ncbicgi.hpp:930
bool m_OwnInput
Definition: ncbicgi.hpp:944
CNcbiIstream * GetValueStream()
Get the value as a stream, potentially on the fly – in which case the caller takes ownership of the s...
Definition: ncbicgi.hpp:1147
unsigned int m_Position
Definition: ncbicgi.hpp:437
CCgiEntry(const char *value, const string &filename=kEmptyStr, unsigned int position=0, const string &type=kEmptyStr)
Definition: ncbicgi.hpp:448
const TCgiIndexes & GetIndexes(void) const
Get a set of indexes(decoded) received from the client.
Definition: ncbicgi.hpp:1192
string x_RetrieveSessionId() const
void SetSecure(bool secure)
Definition: ncbicgi.hpp:1022
pair< TCIter, TCIter > TCRange
Definition: ncbicgi.hpp:225
string m_Domain
Definition: ncbicgi.hpp:158
string m_Path
Definition: ncbicgi.hpp:159
TCgiEntries::iterator TCgiEntriesI
Definition: ncbicgi.hpp:639
TCgiEntries::const_iterator TCgiEntriesCI
Definition: ncbicgi.hpp:640
static bool x_GetString(string *str, const string &val)
TSet::iterator TIter
Definition: ncbicgi.hpp:222
CCgiRequest(const CCgiRequest &)
prohibit default initialization and assignment
bool empty() const
Definition: ncbicgi.hpp:538
int m_InputFD
input file descriptor, if available.
Definition: ncbicgi.hpp:943
string m_Value
Definition: ncbicgi.hpp:157
const TCgiEntries & GetEntries(void) const
Get a set of entries(decoded) received from the client.
Definition: ncbicgi.hpp:1181
NStr::EUrlEncode m_EncodeFlag
Definition: ncbicgi.hpp:342
map< string, string > TCgiProperties
Definition: ncbicgi.hpp:637
SIZE_TYPE find(const char *s, SIZE_TYPE pos=0) const
Definition: ncbicgi.hpp:544
unsigned int & SetPosition()
Definition: ncbicgi.hpp:519
bool m_HttpOnly
Definition: ncbicgi.hpp:162
void SetPath(const string &str)
Definition: ncbicgi.hpp:1015
void SetValue(const string &str)
All SetXXX(const string&) methods beneath:
Definition: ncbicgi.hpp:1007
const string & GetName(void) const
The cookie name cannot be changed during its whole timelife.
Definition: ncbicgi.hpp:1031
CCgiCookie * Find(const string &name, const string &domain, const string &path)
Return NULL if cannot find this exact cookie.
Definition: ncbicgi.cpp:690
SData(const SData &data)
Definition: ncbicgi.hpp:429
const string & GetValue(void) const
All "const string& GetXXX(...)" methods beneath return reference to "NcbiEmptyString" if the requeste...
Definition: ncbicgi.hpp:1034
CCgiEntryReaderContext * m_EntryReaderContext
Definition: ncbicgi.hpp:981
string & SetContentType()
Definition: ncbicgi.hpp:527
void x_SetSession(CCgiSession &session)
Definition: ncbicgi.hpp:1204
int compare(const string &s) const
Definition: ncbicgi.hpp:540
CExtraEntryCollector(void)
Definition: ncbicgi.hpp:662
SIZE_TYPE find_first_of(const char *s, SIZE_TYPE pos=0) const
Definition: ncbicgi.hpp:552
string & SetValue()
Definition: ncbicgi.hpp:475
EWriteMethod
Whether the cookie is sent as a part of HTTP request or HTTP response.
Definition: ncbicgi.hpp:85
TCgiIndexes m_Indexes
set of the request ISINDEX-like indexes(already retrieved; cached)
Definition: ncbicgi.hpp:937
multimap< string, CCgiEntry, PNocase_Conditional > TCgiEntries
Definition: ncbicgi.hpp:638
void SetExpDate(const tm &exp_date)
Definition: ncbicgi.hpp:1019
TSet::const_iterator TCIter
Definition: ncbicgi.hpp:223
void SetUrlEncodeFlag(EUrlEncode encode_flag)
Definition: ncbicgi.hpp:1107
pair< TIter, TIter > TRange
Definition: ncbicgi.hpp:224
void SetValue(IReader *r)
Definition: ncbicgi.hpp:479
string m_TrackingCookie
Definition: ncbicgi.hpp:950
const string & GetValue() const
Get the value as a string, (necessarily) prefetching it all if applicable; the result remains availab...
Definition: ncbicgi.hpp:470
CRef< SData > m_Data
Definition: ncbicgi.hpp:604
On_Bad_Cookie
Definition: ncbicgi.hpp:359
ECgiProp
Set of "standard" HTTP request properties.
Definition: ncbicgi.hpp:378
void SetValue(CNcbiIstream &is, EOwnership own=eNoOwnership)
Definition: ncbicgi.hpp:481
int compare(const char *s) const
Definition: ncbicgi.hpp:541
CDiagContext_Extra::TExtraArgs m_Args
Definition: ncbicgi.hpp:673
void x_ForceComplete() const
Definition: ncbicgi.hpp:1159
const CCgiCookies & GetCookies(void) const
Retrieve the request cookies.
Definition: ncbicgi.hpp:1173
bool m_QueryStringParsed
Definition: ncbicgi.hpp:952
CNcbiIstream * m_Input
input stream
Definition: ncbicgi.hpp:941
bool m_Secure
Definition: ncbicgi.hpp:161
void SetTrackingCookie(const string &cookie_value)
Store/retrieve tracking cookie value.
Definition: ncbicgi.hpp:925
const string & GetContentType() const
May be available for some fields of POSTed forms.
Definition: ncbicgi.hpp:525
const CNcbiEnvironment & GetEnvironment() const
Definition: ncbicgi.hpp:891
CNcbiOstream & Write(CNcbiOstream &os, EWriteMethod wmethod=eHTTPResponse, EUrlEncode flag=eUrlEncode_SkipMarkChars) const
Compose and write to output stream "os":
Definition: ncbicgi.cpp:232
int TInvalidFlag
Definition: ncbicgi.hpp:149
string substr(SIZE_TYPE i=0, SIZE_TYPE n=NPOS) const
Definition: ncbicgi.hpp:542
bool Remove(CCgiCookie *cookie, bool destroy=true)
Remove "cookie" from this set; deallocate it if "destroy" is true Return FALSE if can not find "cooki...
Definition: ncbicgi.cpp:770
TCgiEntries m_Entries
set of the request FORM-like entries(already retrieved; cached)
Definition: ncbicgi.hpp:935
list< string > TCgiIndexes
Definition: ncbicgi.hpp:641
void Clear(void)
Remove all stored cookies.
Definition: ncbicgi.cpp:792
CNcbiOstream & Write(CNcbiOstream &os, CCgiCookie::EWriteMethod wmethod=CCgiCookie::eHTTPResponse) const
Printout all cookies into the stream "os".
Definition: ncbicgi.cpp:670
void SetHttpOnly(bool http_only)
Definition: ncbicgi.hpp:1025
void SetValue(const string &v)
Definition: ncbicgi.hpp:477
CDiagContext_Extra::TExtraArgs & GetArgs(void)
Definition: ncbicgi.hpp:670
CCgiCookies(void)
Empty set of cookies.
Definition: ncbicgi.hpp:1068
void ResetInvalid(TInvalidFlag flag)
Definition: ncbicgi.hpp:1058
IReader * GetValueReader()
Get the value via a reader, potentially on the fly – in which case the caller takes ownership of the ...
Definition: ncbicgi.hpp:1136
unique_ptr< CTrackingEnvHolder > m_TrackingEnvHolder
Definition: ncbicgi.hpp:979
CCgiCookies(const CCgiCookies &)
prohibit default initialization and assignment
const string & GetTrackingCookie(void) const
Definition: ncbicgi.hpp:926
NCBI_XCGI_EXPORT
Parameter to control error handling of incoming cookies.
Definition: ncbicgi.hpp:357
const char * c_str() const
Definition: ncbicgi.hpp:539
bool m_Secure
Definition: ncbicgi.hpp:344
CCgiCookie * Add(const string &name, const string &value, const string &domain=kEmptyStr, const string &path=kEmptyStr, EOnBadCookie on_bad_cookie=eOnBadCookie_SkipAndError)
All Add() functions: if the added cookie has the same {name, domain, path} as an already existing one...
Definition: ncbicgi.cpp:383
const string & GetFilename() const
Only available for certain fields of POSTed forms.
Definition: ncbicgi.hpp:508
unique_ptr< CNcbiEnvironment > m_OwnEnv
Definition: ncbicgi.hpp:931
virtual void AddEntry(const string &name, const string &value, const string &filename, bool is_index=false)=0
bool GetHttpOnly(void) const
Definition: ncbicgi.hpp:1046
SData(const string &value, const string &filename, unsigned int position, const string &type)
Definition: ncbicgi.hpp:425
CCgiCookies m_Cookies
set of the request cookies(already retrieved; cached)
Definition: ncbicgi.hpp:939
void SetPosition(int p)
Definition: ncbicgi.hpp:521
CCgiEntry(const CCgiEntry &e)
Definition: ncbicgi.hpp:453
CCgiSession * m_Session
Definition: ncbicgi.hpp:980
tm m_Expires
Definition: ncbicgi.hpp:160
string operator+(const CCgiEntry &e, const string &s)
Definition: ncbicgi.hpp:611
const string & GetPath(void) const
Definition: ncbicgi.hpp:1040
unique_ptr< string > m_Content
Original request content or NULL if fSaveRequestContent is not set.
Definition: ncbicgi.hpp:933
SIZE_TYPE find_first_of(const string &s, SIZE_TYPE pos=0) const
Definition: ncbicgi.hpp:550
EOnBadCookie
How to handle badly formed cookies.
Definition: ncbicgi.hpp:228
static const size_t kContentLengthUnknown
Get content length using value of the property 'eCgi_ContentLength'.
Definition: ncbicgi.hpp:781
TInvalidFlag m_InvalidFlag
Definition: ncbicgi.hpp:163
void SetInvalid(TInvalidFlag flag)
Definition: ncbicgi.hpp:1054
~CCgiCookies(void)
Destructor.
Definition: ncbicgi.hpp:1123
CCgiEntry & operator=(const CCgiEntry &e)
Definition: ncbicgi.hpp:456
TInvalidFlag IsInvalid(void) const
Definition: ncbicgi.hpp:1050
SIZE_TYPE size() const
commonly-requested string:: operations...
Definition: ncbicgi.hpp:537
bool m_AllHttpOnly
Definition: ncbicgi.hpp:346
bool GetAllCookiesSecure(void) const
Definition: ncbicgi.hpp:324
bool GetSecure(void) const
Definition: ncbicgi.hpp:1043
virtual ~CEntryCollector_Base(void)
Definition: ncbicgi.hpp:652
static void x_CheckField(const string &str, EFieldType ftype, const char *banned_symbols, const string *cookie_name=NULL)
Definition: ncbicgi.cpp:283
bool GetAllCookiesHttpOnly(void) const
Definition: ncbicgi.hpp:328
ERequestMethod
Standard request methods.
Definition: ncbicgi.hpp:905
void x_ForceUnique()
Definition: ncbicgi.hpp:591
int TFlags
Startup initialization.
Definition: ncbicgi.hpp:703
void SetContentType(const string &f)
Definition: ncbicgi.hpp:529
void SetSecure(bool secure)
Set secure connection flag.
Definition: ncbicgi.hpp:320
string m_Name
Definition: ncbicgi.hpp:156
const CCgiCookie * TCPtr
Predicate for the cookie comparison.
Definition: ncbicgi.hpp:136
CNcbiIstream * GetInputStream(void) const
Return pointer to the input stream.
Definition: ncbicgi.hpp:1196
unsigned int GetPosition() const
CGI parameter number – automatic image name parameter is #0, explicit parameters start at #1.
Definition: ncbicgi.hpp:517
const string & GetDomain(void) const
Definition: ncbicgi.hpp:1037
void SetDomain(const string &str)
Definition: ncbicgi.hpp:1011
unique_ptr< IReader > m_Reader
Definition: ncbicgi.hpp:438
size_t m_ErrBufSize
Request initialization error buffer size; when initialization code hits unexpected EOF it will try to...
Definition: ncbicgi.hpp:949
bool Empty(void) const
Return TRUE if this set contains no cookies.
Definition: ncbicgi.hpp:1112
~CExtraEntryCollector(void) override
Definition: ncbicgi.hpp:663
CCgiEntry(const string &value=kEmptyStr, const string &filename=kEmptyStr, unsigned int position=0, const string &type=kEmptyStr)
Definition: ncbicgi.hpp:442
CNcbiOstream & operator<<(CNcbiOstream &os, const CCgiCookie &cookie)
Definition: ncbicgi.hpp:195
EOnCharsetError
Action to perform if the explicit charset is not supported.
Definition: ncbicgi.hpp:499
EUrlEncode GetUrlEncodeFlag(void) const
Definition: ncbicgi.hpp:1101
CGI
Definition: ncbicgi.hpp:359
string & SetFilename()
Definition: ncbicgi.hpp:510
TSet m_Cookies
Definition: ncbicgi.hpp:343
@ eField_Value
Definition: ncbicgi.hpp:167
@ eField_Other
Definition: ncbicgi.hpp:168
@ eHTTPResponse
Definition: ncbicgi.hpp:86
@ eCgi_AuthType
Definition: ncbicgi.hpp:402
@ eCgi_ServerProtocol
Definition: ncbicgi.hpp:383
@ eCgi_ContentType
Definition: ncbicgi.hpp:391
@ eCgi_ServerName
Definition: ncbicgi.hpp:381
@ eCgi_HttpUserAgent
Definition: ncbicgi.hpp:411
@ eCgi_HttpReferer
Definition: ncbicgi.hpp:410
@ eCgi_HttpAccept
Definition: ncbicgi.hpp:407
@ eCgi_PathInfo
Definition: ncbicgi.hpp:396
@ eCgi_RemoteAddr
Definition: ncbicgi.hpp:388
@ eCgi_HttpCookie
Definition: ncbicgi.hpp:408
@ eCgi_ContentLength
Definition: ncbicgi.hpp:392
@ eCgi_RequestMethod
Definition: ncbicgi.hpp:395
@ eCgi_ServerSoftware
Definition: ncbicgi.hpp:380
@ eCgi_NProperties
Definition: ncbicgi.hpp:415
@ eCgi_RemoteHost
Definition: ncbicgi.hpp:387
@ eCgi_PathTranslated
Definition: ncbicgi.hpp:397
@ eCgi_QueryString
Definition: ncbicgi.hpp:399
@ eCgi_ServerPort
Definition: ncbicgi.hpp:384
@ eCgi_HttpIfModifiedSince
Definition: ncbicgi.hpp:409
@ eCgi_RemoteIdent
Definition: ncbicgi.hpp:404
@ eCgi_RemoteUser
Definition: ncbicgi.hpp:403
@ eCgi_GatewayInterface
Definition: ncbicgi.hpp:382
@ eCgi_ScriptName
Definition: ncbicgi.hpp:398
@ eCookieEnc_Url
Definition: ncbicgi.hpp:186
@ eOnBadCookie_StoreAndError
Report error, store bad cookie as-is.
Definition: ncbicgi.hpp:232
@ eOnBadCookie_ThrowException
Throw exception, ignore bad cookie.
Definition: ncbicgi.hpp:229
@ eOnBadCookie_SkipAndError
Report error, ignore bad cookie.
Definition: ncbicgi.hpp:230
@ eOnBadCookie_Skip
Silently ignore bad cookie.
Definition: ncbicgi.hpp:231
@ eCreateIfNotExist
If Session does not exist the new one will be created.
Definition: ncbicgi.hpp:837
@ eCheck_SkipInvalid
Definition: ncbicgi.hpp:333
@ eMethod_OPTIONS
Definition: ncbicgi.hpp:911
@ eMethod_DELETE
Definition: ncbicgi.hpp:910
@ eMethod_CONNECT
Definition: ncbicgi.hpp:913
@ eCharsetError_Ignore
Ignore unknown charset (try to autodetect)
Definition: ncbicgi.hpp:500
@ fInvalid_Value
Definition: ncbicgi.hpp:146
EUrlEncode
Definition: cgi_util.hpp:56
@ eUrlEncode_SkipMarkChars
Definition: cgi_util.hpp:58
#define NULL
Definition: ncbistd.hpp:225
SDiagMessage::TExtraArgs TExtraArgs
Definition: ncbidiag.hpp:1864
void destroy(P pT)
void Write(CObjectOStream &out, TConstObjectPtr object, const CTypeRef &type)
Definition: serial.cpp:55
#define NCBI_PARAM_ENUM_DECL_EXPORT(expname, type, section, name)
Same as NCBI_PARAM_ENUM_DECL but with export specifier (e.g.
Definition: ncbi_param.hpp:194
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
std::string CStringUTF8
Definition: ncbistl.hpp:254
void g_ExtractReaderContents(IReader &reader, string &s)
Append all IReader contents to a given string.
IO_PREFIX::ostream CNcbiOstream
Portable alias for ostream.
Definition: ncbistre.hpp:149
IO_PREFIX::istream CNcbiIstream
Portable alias for istream.
Definition: ncbistre.hpp:146
NCBI_NS_STD::string::size_type SIZE_TYPE
Definition: ncbistr.hpp:132
#define kEmptyStr
Definition: ncbistr.hpp:123
EUrlEncode
URL-encode flags.
Definition: ncbistr.hpp:3143
#define NPOS
Definition: ncbistr.hpp:133
#define NcbiEmptyString
Definition: ncbistr.hpp:122
enum ENcbiOwnership EOwnership
Ownership relations between objects.
int i
yy_size_t n
range(_Ty, _Ty) -> range< _Ty >
mdb_mode_t mode
Definition: lmdb++.h:38
const struct ncbi::grid::netcache::search::fields::KEY key
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
double r(size_t dimension_, const Int4 *score_, const double *prob_, double theta_)
Reader-writer based streams.
Definition: type.c:6
#define _ASSERT
API to parse user agent strings.
void Serialize(CNcbiOstream &, const CRawScoreVector< Key, Score > &)
Generics These throw an exception; we must implement serialization for each type.
void Deserialize(CNcbiIstream &istr, CRawScoreVector< Key, Score > &)
static wxAcceleratorEntry entries[3]
Modified on Fri Sep 20 14:58:14 2024 by modify_doxy.py rev. 669887