sipxtacklib  Version 3.3
HttpMessage.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2007-2008 SIPez LLC All rights reserved.
3 // Licensed to SIPfoundry under a Contributor Agreement.
4 //
5 // Copyright (C) 2004-2008 SIPfoundry Inc.
6 // Licensed by SIPfoundry under the LGPL license.
7 //
8 // Copyright (C) 2004-2006 Pingtel Corp. All rights reserved.
9 // Licensed to SIPfoundry under a Contributor Agreement.
10 //
11 // $$
13 
14 // Author: Dan Petrie (dpetrie AT SIPez DOT com)
15 
16 #ifndef _HttpMessage_h_
17 #define _HttpMessage_h_
18 
19 // SYSTEM INCLUDES
20 
21 // APPLICATION INCLUDES
22 #include <os/OsDefs.h>
23 
24 #include <net/HttpBody.h>
25 #include <net/NameValuePair.h>
26 #include <os/OsSocket.h>
27 #include <os/OsTimeLog.h>
28 #include <os/OsMsgQ.h>
29 #include <os/OsAtomics.h>
30 #include <utl/UtlDList.h>
31 
32 // DEFINES
33 #define HTTP_NAME_VALUE_DELIMITER ':'
34 #define HEADER_LINE_PART_DELIMITER ' '
35 #define END_OF_LINE_DELIMITOR "\r\n"
36 
37 #define PASSWORD_SECRET "xpressa"
38 
39 #define HTTP_DEFAULT_SOCKET_BUFFER_SIZE 10240
40 
41 #define HTTP_LONG_INT_CHARS 20
42 
43 #define HTTP_PROTOCOL_VERSION "HTTP/1.0"
44 #define HTTP_PROTOCOL_VERSION_1_1 "HTTP/1.1"
45 
46 // HTTP Methods
47 #define HTTP_GET_METHOD "GET"
48 #define HTTP_PUT_METHOD "PUT"
49 #define HTTP_POST_METHOD "POST"
50 
51 // Response codes and text
52 #define HTTP_OK_CODE 200
53 #define HTTP_OK_TEXT "OK"
54 #define HTTP_MOVED_PERMANENTLY_CODE 301
55 #define HTTP_MOVED_PERMANENTLY_TEXT "Moved Permanently"
56 #define HTTP_MOVED_TEMPORARILY_CODE 302
57 #define HTTP_MOVED_TEMPORARILY_TEXT "Moved Temporatily"
58 #define HTTP_UNAUTHORIZED_CODE 401
59 #define HTTP_UNAUTHORIZED_TEXT "Unauthorized"
60 #define HTTP_FORBIDDEN_CODE 403
61 #define HTTP_FORBIDDEN_TEXT "Forbidden"
62 #define HTTP_FILE_NOT_FOUND_CODE 404
63 #define HTTP_FILE_NOT_FOUND_TEXT "File Not Found"
64 #define HTTP_PROXY_UNAUTHORIZED_CODE 407
65 #define HTTP_PROXY_UNAUTHORIZED_TEXT "Proxy Authentication Required"
66 #define HTTP_UNSUPPORTED_METHOD_CODE 501
67 #define HTTP_UNSUPPORTED_METHOD_TEXT "Not Implemented"
68 #define HTTP_OUT_OF_RESOURCES_CODE 503
69 #define HTTP_OUT_OF_RESOURCES_TEXT "Out of Resources"
70 
71 // Field names
72 #define HTTP_ACCEPT_LANGUAGE_FIELD "ACCEPT-LANGUAGE"
73 #define HTTP_ACCEPT_ENCODING_FIELD "ACCEPT-ENCODING"
74 #define HTTP_AUTHORIZATION_FIELD "AUTHORIZATION"
75 #define HTTP_DATE_FIELD "DATE"
76 #define HTTP_CONTENT_DISPOSITION_FIELD "CONTENT-DISPOSITION"
77 #define HTTP_CONTENT_TRANSFER_ENCODING_FIELD "CONTENT-TRANSFER-ENCODING"
78 #define HTTP_CONTENT_LENGTH_FIELD "CONTENT-LENGTH"
79 #define HTTP_CONTENT_TYPE_FIELD "CONTENT-TYPE"
80 #define HTTP_CONTENT_ID_FIELD "CONTENT-ID"
81 #define HTTP_LOCATION_FIELD "LOCATION"
82 #define HTTP_PROXY_AUTHENTICATE_FIELD "PROXY-AUTHENTICATE"
83 #define HTTP_PROXY_AUTHORIZATION_FIELD "PROXY-AUTHORIZATION"
84 #define HTTP_REFRESH_FIELD "REFRESH"
85 #define HTTP_USER_AGENT_FIELD "USER-AGENT"
86 #define HTTP_WWW_AUTHENTICATE_FIELD "WWW-AUTHENTICATE"
87 #define HTTP_HOST_FIELD "HOST"
88 #define HTTP_ACCEPT_FIELD "ACCEPT"
89 #define HTTP_CONNECTION_FIELD "CONNECTION"
90 
91 // Authentication Constants
92 // these are by specification case-independant tokens,
93 // but we always send the case as used in the examples in
94 // the spec (rfc2617)
95 #define HTTP_BASIC_AUTHENTICATION "Basic"
96 #define HTTP_DIGEST_AUTHENTICATION "Digest"
97 #define HTTP_AUTHENTICATION_ALGORITHM_TOKEN "algorithm"
98 # define HTTP_MD5_ALGORITHM "MD5"
99 # define HTTP_MD5_SESSION_ALGORITHM "MD5-sess"
100 #define HTTP_AUTHENTICATION_CNONCE_TOKEN "cnonce"
101 #define HTTP_AUTHENTICATION_DOMAIN_TOKEN "domain"
102 #define HTTP_AUTHENTICATION_REALM_TOKEN "realm"
103 #define HTTP_AUTHENTICATION_NONCE_TOKEN "nonce"
104 #define HTTP_AUTHENTICATION_NONCE_COUNT_TOKEN "nc"
105 #define HTTP_AUTHENTICATION_OPAQUE_TOKEN "opaque"
106 #define HTTP_AUTHENTICATION_QOP_TOKEN "qop"
107 # define HTTP_QOP_AUTH "auth"
108 # define HTTP_QOP_AUTH_INTEGRITY "auth-int"
109 #define HTTP_AUTHENTICATION_USERNAME_TOKEN "username"
110 #define HTTP_AUTHENTICATION_URI_TOKEN "uri"
111 #define HTTP_AUTHENTICATION_RESPONSE_TOKEN "response"
112 
113 // HTTP_CONTENT_TRANSFER_ENCODING types
114 #define HTTP_CONTENT_TRANSFER_ENCODING_BINARY "binary"
115 #define HTTP_CONTENT_TRANSFER_ENCODING_BASE64 "base64"
116 
117 // Content-Type field parameters
118 #define HTTP_CONTENT_TYPE_PARAM_ACCESS_TYPE "access-type"
119 #define HTTP_CONTENT_TYPE_PARAM_EXPIRATION "expiration"
120 #define HTTP_CONTENT_TYPE_PARAM_HASH "hash"
121 #define HTTP_CONTENT_TYPE_PARAM_SIZE "size"
122 #define HTTP_CONTENT_TYPE_PARAM_URL "url"
123 
124 // MACROS
125 // EXTERNAL FUNCTIONS
126 // EXTERNAL VARIABLES
127 // CONSTANTS
128 const int HttpMessageRetries = 2;
129 
130 // STRUCTS
131 
132 // FORWARD DECLARATIONS
133 class UtlString;
134 class Url;
135 class HttpMessage;
136 class OsConnectionSocket;
137 class UtlHashMap;
138 
139 // TYPEDEFS
142 typedef UtlBoolean (*GetDataCallbackProc)(char* pData,
143  int iLength,
144  void* pOptionalData,
145  HttpMessage* pMsg);
146 
147 
149 
192 {
193 /* //////////////////////////// PUBLIC //////////////////////////////////// */
194 public:
195 
197  {
198  SERVER = 0,
200  };
201 
202 /* ============================ CREATORS ================================== */
203 
205  HttpMessage(const char* messageBytes = NULL,
206  int byteCount = -1);
207 
209  HttpMessage(OsSocket* inSocket,
210  int bufferSize = HTTP_DEFAULT_SOCKET_BUFFER_SIZE);
211 
213  HttpMessage(const HttpMessage& rHttpMessage);
214 
216  HttpMessage& operator=(const HttpMessage& rhs);
217 
219  virtual
220  ~HttpMessage();
221 
222 /* ============================ MANIPULATORS ============================== */
223 
225 
230  int get(Url& httpUrl,
231  int maxWaitMilliSeconds,
232  bool bPersistent=true);
233 
235 
240  int get(Url& httpUrl,
241  HttpMessage& request,
242  int maxWaitMilliSeconds,
243  bool bPersistent=false);
244 
245 
248 
262  OsStatus get(Url& httpUrl,
263  int maxWaitMilliSeconds,
264  GetDataCallbackProc callbackProc,
265  void* optionalData = NULL,
266  OsConnectionSocket** socket = NULL) ;
267 
269 
289  int read(OsSocket* inSocket,
290  int bufferSize = HTTP_DEFAULT_SOCKET_BUFFER_SIZE,
291  UtlString* externalBuffer = NULL,
292  int maxContentLength = 6000000);
293 
296  int readHeader(OsSocket* inSocket, UtlString& buffer);
297 
300  int readBody(OsSocket* inSocket, int length, GetDataCallbackProc callbackProc, void* optionalData);
301 
303 
306  UtlBoolean write(OsSocket* outSocket) const;
307 
310  static void cannonizeToken(UtlString& token);
311 
313  static void unescape(UtlString& escapedText);
314 
317  static void escapeChars(UtlString& unEscapedText, UtlString& tobeEscapedChars);
318 
320  static void escape(UtlString& unEscapedText);
321 
323  static void escapeOneChar(UtlString& unEscapedText, char tobeEscapedChar);
324 
330  int parseFirstLine(const char* messageBytes, int byteCount);
332 
334 
338  void parseMessage(const char* messageBytes, int byteCount);
339 
341  void parseBody(const char* messageBodyBytes, int byteCount);
342 
344  static int parseHeaders(const char* headerBytes,
345  int messageLength,
346  UtlDList& headerNameValues);
347 
349 
351  static int findHeaderEnd(const char* messageBytes, int messageLength);
352 
354 /* ============================ ACCESSORS ================================= */
355 
356  static OsAtomicInt smHttpMessageCount;
357  static int getHttpMessageCount();
358 
359  const char* getFirstHeaderLine() const;
360 
362 
364  void setFirstHeaderLine(const char* newHeaderLine);
365 
366 
367  void setFirstHeaderLine(const char* subfields0,
368  const char* subfield1,
369  const char* subfield2);
370 
372 
375  void getFirstHeaderLinePart(int partIndex,
376  UtlString* part,
377  char separator = HEADER_LINE_PART_DELIMITER) const;
378 
380 
386  void setTransportTime(long timeStamp);
387  void touchTransportTime();
388  long getTransportTime() const;
389 
392  void setResendDuration(int resendMSec);
393  int getResendDuration() const;
394 
395  // Used by transport to track reliably the number of times the
396  // message was sent (and resent).
397  int getTimesSent() const;
398  void incrementTimesSent();
399  void setTimesSent(int times = 0);
400 
401  // Used by the tranport to track reliably which protocol the
402  // message was sent over
403  void setSendProtocol(OsSocket::IpProtocolSocketType protocol = OsSocket::TCP);
404  OsSocket::IpProtocolSocketType getSendProtocol() const;
405 
406  void setFirstSent();
407  void setSendAddress(const char* address, int port);
408  void getSendAddress(UtlString* address, int* port) const;
409 
410  // Resets the tranport state stuff
411  void resetTransport();
413 
415 
419 
422  OsMsgQ* getResponseListenerQueue() const;
423 
426  void setResponseListenerQueue(OsMsgQ* requestListenerQueue);
427 
429  void* getResponseListenerData() const;
430 
432  void setResponseListenerData(void* requestListenerData);
434 
435 
437 
441 
443  int getCountHeaderFields(const char* name = NULL) const;
444 
447 
453  const char* getHeaderValue(int index, const char* name = NULL) const;
454 
456 
463  void setHeaderValue(const char* name, const char* newValue, int index = 0);
464 
466 
470  void addHeaderField(const char* name, const char* value);
471 
472 
475 
480  void insertHeaderField(const char* name,
481  const char* value,
482  int index = 0);
483 
484 
485  UtlBoolean removeHeader(const char* name, int index);
487 
492 
494 
495  void setContentType(const char* contentTypeString,
496  const char* accessType = NULL,
497  const char* expirationDate = NULL,
498  const char* url = NULL,
499  int size = -1,
500  const char* hash = NULL);
501 
502  UtlBoolean getContentType(UtlString* contentType, UtlHashMap* parameters = NULL) const;
503 
504  void setContentLength(int contentLength);
505 
506  int getContentLength() const;
507 
508  void setUserAgentField(const char* userAgentFieldValue);
509 
510  void getUserAgentField(UtlString* userAgentFieldValue) const;
511 
512  void setRefresh(int seconds, const char* refreshUrl = NULL);
513 
514  UtlBoolean getDateField(long* epochDate) const;
515 
517  void setDateField();
518 
519  void setAcceptLanguageField(const char* acceptLanaguageFieldValue);
520 
521  void getAcceptLanguageField(UtlString* acceptLanaguageFieldValue) const;
522 
523  UtlBoolean getAcceptField(UtlString& acceptValue) const;
524 
525  void setLocationField(const char* locationField);
527 
529 
530  const HttpBody* getBody() const;
532 
538  void setBody(HttpBody* newBody);
540 
542 
546  void getBytes(UtlString* bytes, int* length) const;
547 
548 
550 
551  UtlBoolean getAuthenticationScheme(UtlString* scheme,
552  int authorizationEntity) const;
553 
554  UtlBoolean getAuthenticationData(UtlString* scheme,
555  UtlString* realm,
556  UtlString* nonce,
557  UtlString* opaque,
558  UtlString* algorithm, // MD5 or MD5-sess
559  UtlString* qop, // may be multiple values
560  int authorizationEntity) const;
561 
562  void setAuthenticationData(const char* scheme, const char* realm,
563  const char* nonce, const char* opaque,
564  const char* domain = NULL,
565  enum HttpEndpointEnum authEntity = SERVER);
566 
567  void addAuthenticationField(const char* authenticationField,
568  enum HttpEndpointEnum authType);
569 
570  UtlBoolean getAuthenticationField(int index,
571  enum HttpEndpointEnum authEntity,
572  const char* authenticationField) const;
573 
574  void addAuthenticationField(const char * AuthorizeField,
575  const char * AuthorizeValue,
576  UtlBoolean otherAuthentications = TRUE);
577  // Authorization methods
578  static void buildBasicAuthorizationCookie(const char* user,
579  const char* password,
580  UtlString* cookie);
581 
582  virtual void setRequestUnauthorized(const HttpMessage* request,
583  const char* authenticationScheme,
584  const char* authenticationRealm,
585  const char* authenticationNonce = NULL,
586  const char* authenticationOpaque = NULL,
587  const char* authenticationDomain = NULL);
588 
589  UtlBoolean getAuthorizationUser(UtlString* userId) const;
590 
591  UtlBoolean getAuthorizationScheme(UtlString* scheme) const;
592 
593  UtlBoolean getAuthorizationField(UtlString* authenticationField,
594  int authorizationEntity) const;
595 
596  void setBasicAuthorization(const char* user, const char* password,
597  int authorizationEntity);
598 
599  UtlBoolean getBasicAuthorizationData(UtlString* encodedCookie) const;
600 
601  UtlBoolean getBasicAuthorizationData(UtlString* userId,
602  UtlString* password) const;
603 
604  UtlBoolean verifyBasicAuthorization(const char* user,
605  const char* password) const;
606 
607  // Digest Authorization
608  void setDigestAuthorizationData(const char* user,
609  const char* realm,
610  const char* nonce,
611  const char* uri,
612  const char* response,
613  const char* algorithm,
614  const char* cnonce,
615  const char* opaque,
616  const char* qop,
617  int nonceCount,
618  int authorizationEntity);
619 
620  UtlBoolean getDigestAuthorizationData(UtlString* user,
621  UtlString* realm = NULL,
622  UtlString* nonce = NULL,
623  UtlString* opaque = NULL,
624  UtlString* response = NULL,
625  UtlString* uri = NULL,
626  int authorizationEntity = HttpMessage::PROXY ,
627  int index = 0) const;
628 
629  static void buildMd5UserPasswordDigest(const char* user,
630  const char* realm,
631  const char* password,
632  UtlString& userPasswordDigest);
633 
634  static void buildMd5Digest(const char* userPasswordDigest,
635  const char* algorithm,
636  const char* nonce,
637  const char* cnonce,
638  int nonceCount,
639  const char* qop,
640  const char* method,
641  const char* uri,
642  const char* bodyDigest,
643  UtlString* responseToken);
644 
645  UtlBoolean verifyMd5Authorization(const char* userId,
646  const char* password,
647  const char* nonce,
648  const char* realm,
649  const char* thisMessageMethod = NULL,
650  const char* thisMessageUri = NULL,
651  enum HttpEndpointEnum authEntity = SERVER) const;
652 
653  UtlBoolean verifyMd5Authorization(const char* userPasswordDigest,
654  const char* nonce,
655  const char* thisMessageMethod = NULL,
656  const char* thisMessageUri = NULL) const;
657 
659 
661 
662  void setResponseFirstHeaderLine(const char* protocol,
663  int statusCode,
664  const char* statusText);
665 
667  void getResponseProtocol(UtlString* protocol) const;
668 
670  int getResponseStatusCode() const;
671 
673  void getResponseStatusText(UtlString* text) const;
675 
676 
677 
681  void setRequestFirstHeaderLine(const char* method,
682  const char* uri,
683  const char* protocol);
684 
686  void getRequestMethod(UtlString* method) const;
687 
689  void getRequestUri(UtlString* uri) const;
690 
692  void getRequestProtocol(UtlString* protocol) const;
693 
695  void changeRequestUri(const char* newUri);
697 
698  // Time logging
699  void logTimeEvent(const char* eventName);
700  void dumpTimeLog() const;
701 
702 /* ============================ INQUIRY =================================== */
703 
704  static UtlBoolean isWholeMessage(const char* messageBuffer,
705  int bufferLength,
706  int& numberBytesChecked,
707  int& contentLength);
708 
709  UtlBoolean isFirstSend() const;
710 
711 /* //////////////////////////// PROTECTED ///////////////////////////////// */
712 protected:
713  UtlDList mNameValues;
714  UtlString mFirstHeaderLine;
715  UtlBoolean mHeaderCacheClean;
716 
717 /* //////////////////////////// PRIVATE /////////////////////////////////// */
718 private:
719 
720  HttpBody* body;
721  long transportTimeStamp;
722  int lastResendDuration;
723  OsSocket::IpProtocolSocketType transportProtocol;
724  int timesSent;
725  UtlBoolean mFirstSent;
726  UtlString mSendAddress;
727  int mSendPort;
728  OsMsgQ* mpResponseListenerQueue;
729  void* mResponseListenerData;
730 #ifdef HTTP_TIMELOG
731  OsTimeLog mTimeLog;
732 #endif
733 
735  NameValuePair* getHeaderField(int index, const char* name = NULL) const;
736 
737 
738 };
739 
740 /* ============================ INLINE METHODS ============================ */
741 
742 #endif // _HttpMessage_h_
int getResendDuration() const
Definition: HttpMessage.cpp:1861
const char * getHeaderValue(int index, const char *name=NULL) const
Get the value of the header field (i.e. second header line).
Definition: HttpMessage.cpp:2021
UtlBoolean getDigestAuthorizationData(UtlString *user, UtlString *realm=NULL, UtlString *nonce=NULL, UtlString *opaque=NULL, UtlString *response=NULL, UtlString *uri=NULL, int authorizationEntity=HttpMessage::PROXY, int index=0) const
Definition: HttpMessage.cpp:2828
void incrementTimesSent()
Definition: HttpMessage.cpp:1871
void getRequestProtocol(UtlString *protocol) const
Get this request&#39;s application layer protocol type.
Definition: HttpMessage.cpp:2581
virtual void setRequestUnauthorized(const HttpMessage *request, const char *authenticationScheme, const char *authenticationRealm, const char *authenticationNonce=NULL, const char *authenticationOpaque=NULL, const char *authenticationDomain=NULL)
Definition: HttpMessage.cpp:3363
UtlBoolean mHeaderCacheClean
Definition: HttpMessage.h:715
HttpEndpointEnum
Definition: HttpMessage.h:196
void setTimesSent(int times=0)
Definition: HttpMessage.cpp:1876
static void cannonizeToken(UtlString &token)
Converts the given token to initial cap capitialization in the style used in RFC 822 header names...
Definition: HttpMessage.cpp:1737
static void escapeOneChar(UtlString &unEscapedText, char tobeEscapedChar)
Selectively URL escape the text if the char is tobeEscapedChar.
Definition: HttpMessage.cpp:1689
UtlBoolean getAcceptField(UtlString &acceptValue) const
Definition: HttpMessage.cpp:2333
static int findHeaderEnd(const char *messageBytes, int messageLength)
returns: the number of bytes in the message buffer which constitue the message header ...
Definition: HttpMessage.cpp:405
void getRequestMethod(UtlString *method) const
Get this request&#39;s method.
Definition: HttpMessage.cpp:2570
static UtlBoolean isWholeMessage(const char *messageBuffer, int bufferLength, int &numberBytesChecked, int &contentLength)
Definition: HttpMessage.cpp:3552
UtlBoolean getAuthenticationScheme(UtlString *scheme, int authorizationEntity) const
Definition: HttpMessage.cpp:2598
UtlBoolean getAuthorizationUser(UtlString *userId) const
Definition: HttpMessage.cpp:2761
Definition: HttpMessage.h:198
int getCountHeaderFields(const char *name=NULL) const
Find the number of occurrences of header fields with the given name.
Definition: HttpMessage.cpp:1940
int readBody(OsSocket *inSocket, int length, GetDataCallbackProc callbackProc, void *optionalData)
Read the body of the specified data and deliever via the callback proc.
Definition: HttpMessage.cpp:1064
void setLocationField(const char *locationField)
Definition: HttpMessage.cpp:2359
void resetTransport()
Definition: HttpMessage.cpp:1909
void getAcceptLanguageField(UtlString *acceptLanaguageFieldValue) const
Definition: HttpMessage.cpp:2344
void setDateField()
Sets the date field to the current time.
Definition: HttpMessage.cpp:2259
void setTransportTime(long timeStamp)
Definition: HttpMessage.cpp:1838
UtlBoolean getContentType(UtlString *contentType, UtlHashMap *parameters=NULL) const
Definition: HttpMessage.cpp:2136
void setAuthenticationData(const char *scheme, const char *realm, const char *nonce, const char *opaque, const char *domain=NULL, enum HttpEndpointEnum authEntity=SERVER)
Definition: HttpMessage.cpp:2623
void dumpTimeLog() const
Definition: HttpMessage.cpp:1793
void setAcceptLanguageField(const char *acceptLanaguageFieldValue)
Definition: HttpMessage.cpp:2354
void setResponseFirstHeaderLine(const char *protocol, int statusCode, const char *statusText)
Definition: HttpMessage.cpp:2527
UtlBoolean getAuthenticationData(UtlString *scheme, UtlString *realm, UtlString *nonce, UtlString *opaque, UtlString *algorithm, UtlString *qop, int authorizationEntity) const
Definition: HttpMessage.cpp:2696
UtlDList mNameValues
Definition: HttpMessage.h:713
int read(OsSocket *inSocket, int bufferSize=HTTP_DEFAULT_SOCKET_BUFFER_SIZE, UtlString *externalBuffer=NULL, int maxContentLength=6000000)
Read HTTP message from socket.
Definition: HttpMessage.cpp:1107
HTTP message container.
Definition: HttpMessage.h:191
static void buildBasicAuthorizationCookie(const char *user, const char *password, UtlString *cookie)
Definition: HttpMessage.cpp:3344
#define HTTP_DEFAULT_SOCKET_BUFFER_SIZE
Definition: HttpMessage.h:39
void changeRequestUri(const char *newUri)
Change this request&#39;s URI.
Definition: HttpMessage.cpp:2588
void setResponseListenerData(void *requestListenerData)
Sets the data item to pass to the request listener.
Definition: HttpMessage.cpp:1935
UtlBoolean removeHeader(const char *name, int index)
Definition: HttpMessage.cpp:2050
long getTransportTime() const
Definition: HttpMessage.cpp:1851
static OsAtomicInt smHttpMessageCount
Definition: HttpMessage.h:356
HttpMessage & operator=(const HttpMessage &rhs)
Assignment operator.
Definition: HttpMessage.cpp:201
void setBody(HttpBody *newBody)
Attach the body section of the message.
Definition: HttpMessage.cpp:2127
void setContentLength(int contentLength)
Definition: HttpMessage.cpp:2277
UtlBoolean getAuthorizationScheme(UtlString *scheme) const
Definition: HttpMessage.cpp:3400
UtlBoolean getBasicAuthorizationData(UtlString *encodedCookie) const
Definition: HttpMessage.cpp:3411
static int parseHeaders(const char *headerBytes, int messageLength, UtlDList &headerNameValues)
returns: the number of bytes parsed
Definition: HttpMessage.cpp:455
UtlBoolean isFirstSend() const
Definition: HttpMessage.cpp:3560
UtlBoolean verifyMd5Authorization(const char *userId, const char *password, const char *nonce, const char *realm, const char *thisMessageMethod=NULL, const char *thisMessageUri=NULL, enum HttpEndpointEnum authEntity=SERVER) const
Definition: HttpMessage.cpp:3205
int readHeader(OsSocket *inSocket, UtlString &buffer)
Will read bytes off the socket until the header of the message is believed received.
Definition: HttpMessage.cpp:1004
void parseBody(const char *messageBodyBytes, int byteCount)
Parses the bytes into a single or multipart body.
Definition: HttpMessage.cpp:369
const HttpBody * getBody() const
Get the body section of the message.
Definition: HttpMessage.cpp:2122
void setRequestFirstHeaderLine(const char *method, const char *uri, const char *protocol)
Definition: HttpMessage.cpp:2556
void addHeaderField(const char *name, const char *value)
Adds a new header line.
Definition: HttpMessage.cpp:2102
int getContentLength() const
Definition: HttpMessage.cpp:2268
const char * getFirstHeaderLine() const
Definition: HttpMessage.cpp:1805
static void unescape(UtlString &escapedText)
URL unescape the text to human readable form.
Definition: HttpMessage.cpp:1542
void getUserAgentField(UtlString *userAgentFieldValue) const
Definition: HttpMessage.cpp:2284
void insertHeaderField(const char *name, const char *value, int index=0)
Inserts a new header line, shifting existing headers at and after the secified location down by one...
Definition: HttpMessage.cpp:2111
Definition: NameValuePair.h:35
UtlBoolean verifyBasicAuthorization(const char *user, const char *password) const
Definition: HttpMessage.cpp:3497
void setDigestAuthorizationData(const char *user, const char *realm, const char *nonce, const char *uri, const char *response, const char *algorithm, const char *cnonce, const char *opaque, const char *qop, int nonceCount, int authorizationEntity)
Definition: HttpMessage.cpp:2957
static void escape(UtlString &unEscapedText)
URL sscape the text.
Definition: HttpMessage.cpp:1651
void setFirstHeaderLine(const char *newHeaderLine)
Set the header line.
Definition: HttpMessage.cpp:1810
void setHeaderValue(const char *name, const char *newValue, int index=0)
Sets the value of an existing header field.
Definition: HttpMessage.cpp:2034
int getResponseStatusCode() const
Get this response&#39;s status code.
Definition: HttpMessage.cpp:2541
static void buildMd5UserPasswordDigest(const char *user, const char *realm, const char *password, UtlString &userPasswordDigest)
Definition: HttpMessage.cpp:3080
void getResponseStatusText(UtlString *text) const
Get this response&#39;s status code text.
Definition: HttpMessage.cpp:2549
HttpMessage(const char *messageBytes=NULL, int byteCount=-1)
Construct from a string.
Definition: HttpMessage.cpp:75
UtlBoolean getAuthenticationField(int index, enum HttpEndpointEnum authEntity, const char *authenticationField) const
Definition: HttpMessage.cpp:2918
void setResponseListenerQueue(OsMsgQ *requestListenerQueue)
Sets the queue on which responses from the same transaction are deposited.
Definition: HttpMessage.cpp:1925
const int HttpMessageRetries
Definition: HttpMessage.h:128
static void buildMd5Digest(const char *userPasswordDigest, const char *algorithm, const char *nonce, const char *cnonce, int nonceCount, const char *qop, const char *method, const char *uri, const char *bodyDigest, UtlString *responseToken)
Definition: HttpMessage.cpp:3119
void setSendProtocol(OsSocket::IpProtocolSocketType protocol=OsSocket::TCP)
Definition: HttpMessage.cpp:1881
void setSendAddress(const char *address, int port)
Definition: HttpMessage.cpp:1896
OsMsgQ * getResponseListenerQueue() const
Gets the queue on which responses from the same transaction are deposited.
Definition: HttpMessage.cpp:1920
void setFirstSent()
Definition: HttpMessage.cpp:1891
UtlBoolean getAuthorizationField(UtlString *authenticationField, int authorizationEntity) const
Definition: HttpMessage.cpp:2805
int parseFirstLine(const char *messageBytes, int byteCount)
Parse the first line of the request or response.
Definition: HttpMessage.cpp:283
void parseMessage(const char *messageBytes, int byteCount)
Parse the message from a byte buffer.
Definition: HttpMessage.cpp:321
void touchTransportTime()
Definition: HttpMessage.cpp:1843
void setContentType(const char *contentTypeString, const char *accessType=NULL, const char *expirationDate=NULL, const char *url=NULL, int size=-1, const char *hash=NULL)
Definition: HttpMessage.cpp:2187
void getBytes(UtlString *bytes, int *length) const
Get the bytes for the compete message.
Definition: HttpMessage.cpp:2364
int getTimesSent() const
Definition: HttpMessage.cpp:1866
void getFirstHeaderLinePart(int partIndex, UtlString *part, char separator=HEADER_LINE_PART_DELIMITER) const
Get part of header line.
Definition: HttpMessage.cpp:2480
void * getResponseListenerData() const
Gets the data item to pass to the request listener.
Definition: HttpMessage.cpp:1930
void getResponseProtocol(UtlString *protocol) const
Get this response&#39;s message protocol.
Definition: HttpMessage.cpp:2536
#define HEADER_LINE_PART_DELIMITER
Definition: HttpMessage.h:34
Definition: HttpMessage.h:199
void getRequestUri(UtlString *uri) const
Get this request&#39;s URI.
Definition: HttpMessage.cpp:2576
void setUserAgentField(const char *userAgentFieldValue)
Definition: HttpMessage.cpp:2294
URL parser and constructor.
Definition: Url.h:90
class to contain an HTTP body
Definition: HttpBody.h:55
UtlBoolean getDateField(long *epochDate) const
Definition: HttpMessage.cpp:2313
void getSendAddress(UtlString *address, int *port) const
Definition: HttpMessage.cpp:1903
UtlString mFirstHeaderLine
Definition: HttpMessage.h:714
void setRefresh(int seconds, const char *refreshUrl=NULL)
Definition: HttpMessage.cpp:2299
void addAuthenticationField(const char *authenticationField, enum HttpEndpointEnum authType)
Definition: HttpMessage.cpp:2901
UtlBoolean(* GetDataCallbackProc)(char *pData, int iLength, void *pOptionalData, HttpMessage *pMsg)
Callback method used as part of HttpMessage::get. If the callback method returns FALSE, then the retrieve is aborted.
Definition: HttpMessage.h:142
void logTimeEvent(const char *eventName)
Definition: HttpMessage.cpp:1786
virtual ~HttpMessage()
Destructor.
Definition: HttpMessage.cpp:168
void setResendDuration(int resendMSec)
Used for transport to track reliably the last duration waited before resending.
Definition: HttpMessage.cpp:1856
static int getHttpMessageCount()
Definition: HttpMessage.cpp:1800
UtlBoolean write(OsSocket *outSocket) const
Write message to socket.
Definition: HttpMessage.cpp:1531
void setBasicAuthorization(const char *user, const char *password, int authorizationEntity)
Definition: HttpMessage.cpp:3376
OsSocket::IpProtocolSocketType getSendProtocol() const
Definition: HttpMessage.cpp:1886
static void escapeChars(UtlString &unEscapedText, UtlString &tobeEscapedChars)
Selectively URL escape the text if they are contained in tobeEscapedChars.
Definition: HttpMessage.cpp:1725

sipXtackLib home page