Changeset 874:8d8a4a023037


Ignore:
Timestamp:
06/25/08 21:33:30 (4 years ago)
Author:
niam
Branch:
libdodo
Message:

updated eclipse code style configuration; io::network::http: new setAuthInfo method

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • eclipse.code.style.xml

    r850 r874  
    33<profile kind="CodeFormatterProfile" name="niam" version="1"> 
    44<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_method_declaration" value="do not insert"/> 
    5 <setting id="org.eclipse.cdt.core.formatter.continuation_indentation" value="2"/> 
    65<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_for" value="do not insert"/> 
    76<setting id="org.eclipse.cdt.core.formatter.insert_new_line_in_empty_block" value="insert"/> 
    87<setting id="org.eclipse.cdt.core.formatter.lineSplit" value="80"/> 
    9 <setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_method_declaration" value="do not insert"/> 
    10 <setting id="org.eclipse.cdt.core.formatter.insert_space_before_colon_in_default" value="do not insert"/> 
     8<setting id="org.eclipse.cdt.core.formatter.insert_space_before_comma_in_base_types" value="do not insert"/> 
    119<setting id="org.eclipse.cdt.core.formatter.keep_else_statement_on_same_line" value="false"/> 
    12 <setting id="org.eclipse.cdt.core.formatter.alignment_for_conditional_expression" value="0"/> 
    1310<setting id="org.eclipse.cdt.core.formatter.indent_switchstatements_compare_to_switch" value="true"/> 
    1411<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_brace_in_array_initializer" value="insert"/> 
    15 <setting id="org.eclipse.cdt.core.formatter.insert_space_before_comma_in_array_initializer" value="do not insert"/> 
    1612<setting id="org.eclipse.cdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters" value="do not insert"/> 
    17 <setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_if" value="do not insert"/> 
    18 <setting id="org.eclipse.cdt.core.formatter.format_guardian_clause_on_one_line" value="false"/> 
    19 <setting id="org.eclipse.cdt.core.formatter.indent_access_specifier_compare_to_type_header" value="true"/> 
    2013<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_if" value="do not insert"/> 
    21 <setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_type_declaration" value="insert"/> 
    22 <setting id="org.eclipse.cdt.core.formatter.continuation_indentation_for_array_initializer" value="2"/> 
    23 <setting id="org.eclipse.cdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters" value="insert"/> 
     14<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression" value="do not insert"/> 
     15<setting id="org.eclipse.cdt.core.formatter.insert_space_after_comma_in_base_types" value="insert"/> 
    2416<setting id="org.eclipse.cdt.core.formatter.indent_body_declarations_compare_to_access_specifier" value="true"/> 
    25 <setting id="org.eclipse.cdt.core.formatter.insert_space_after_semicolon_in_for" value="insert"/> 
     17<setting id="org.eclipse.cdt.core.formatter.insert_space_after_comma_in_template_arguments" value="insert"/> 
    2618<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_block" value="insert"/> 
    2719<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_method_declaration" value="do not insert"/> 
    28 <setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_method_invocation" value="do not insert"/> 
    2920<setting id="org.eclipse.cdt.core.formatter.use_tabs_only_for_leading_indentations" value="false"/> 
    30 <setting id="org.eclipse.cdt.core.formatter.indent_body_declarations_compare_to_namespace_header" value="true"/> 
     21<setting id="org.eclipse.cdt.core.formatter.insert_space_before_colon_in_labeled_statement" value="do not insert"/> 
    3122<setting id="org.eclipse.cdt.core.formatter.insert_space_after_colon_in_case" value="insert"/> 
    32 <setting id="org.eclipse.cdt.core.formatter.insert_space_after_closing_brace_in_block" value="insert"/> 
    33 <setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_array_initializer" value="insert"/> 
    34 <setting id="org.eclipse.cdt.core.formatter.insert_new_line_at_end_of_file_if_missing" value="do not insert"/> 
    3523<setting id="org.eclipse.cdt.core.formatter.insert_space_after_comma_in_array_initializer" value="insert"/> 
    36 <setting id="org.eclipse.cdt.core.formatter.alignment_for_expressions_in_array_initializer" value="50"/> 
    37 <setting id="org.eclipse.cdt.core.formatter.insert_space_before_question_in_conditional" value="insert"/> 
     24<setting id="org.eclipse.cdt.core.formatter.insert_space_after_comma_in_enum_declarations" value="insert"/> 
     25<setting id="org.eclipse.cdt.core.formatter.alignment_for_expressions_in_array_initializer" value="82"/> 
     26<setting id="org.eclipse.cdt.core.formatter.insert_space_after_comma_in_declarator_list" value="insert"/> 
     27<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_bracket" value="do not insert"/> 
    3828<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_for" value="do not insert"/> 
     29<setting id="org.eclipse.cdt.core.formatter.insert_space_before_prefix_operator" value="do not insert"/> 
    3930<setting id="org.eclipse.cdt.core.formatter.tabulation.size" value="4"/> 
    40 <setting id="org.eclipse.cdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments" value="do not insert"/> 
    4131<setting id="org.eclipse.cdt.core.formatter.insert_new_line_before_else_in_if_statement" value="insert"/> 
    42 <setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_switch" value="insert"/> 
    43 <setting id="org.eclipse.cdt.core.formatter.indent_statements_compare_to_body" value="true"/> 
     32<setting id="org.eclipse.cdt.core.formatter.alignment_for_enumerator_list" value="48"/> 
     33<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression" value="do not insert"/> 
    4434<setting id="org.eclipse.cdt.core.formatter.insert_space_between_empty_parens_in_method_declaration" value="do not insert"/> 
    45 <setting id="org.eclipse.cdt.core.formatter.indent_statements_compare_to_block" value="true"/> 
     35<setting id="org.eclipse.cdt.core.formatter.alignment_for_declarator_list" value="16"/> 
    4636<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_switch" value="do not insert"/> 
    47 <setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_method_invocation" value="do not insert"/> 
     37<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression" value="do not insert"/> 
    4838<setting id="org.eclipse.cdt.core.formatter.indent_empty_lines" value="false"/> 
    49 <setting id="org.eclipse.cdt.core.formatter.tabulation.char" value="tab"/> 
    5039<setting id="org.eclipse.cdt.core.formatter.indent_switchstatements_compare_to_cases" value="true"/> 
    5140<setting id="org.eclipse.cdt.core.formatter.keep_empty_array_initializer_on_one_line" value="false"/> 
     
    5342<setting id="org.eclipse.cdt.core.formatter.put_empty_statement_on_new_line" value="true"/> 
    5443<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_switch" value="insert"/> 
    55 <setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_while" value="do not insert"/> 
     44<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_cast" value="do not insert"/> 
    5645<setting id="org.eclipse.cdt.core.formatter.insert_space_between_empty_braces_in_array_initializer" value="do not insert"/> 
    5746<setting id="org.eclipse.cdt.core.formatter.brace_position_for_method_declaration" value="next_line"/> 
     47<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_while" value="do not insert"/> 
     48<setting id="org.eclipse.cdt.core.formatter.insert_space_after_question_in_conditional" value="insert"/> 
     49<setting id="org.eclipse.cdt.core.formatter.insert_space_before_semicolon" value="do not insert"/> 
     50<setting id="org.eclipse.cdt.core.formatter.insert_space_after_closing_angle_bracket_in_template_arguments" value="insert"/> 
     51<setting id="org.eclipse.cdt.core.formatter.insert_space_before_colon_in_base_clause" value="insert"/> 
     52<setting id="org.eclipse.cdt.core.formatter.indent_breaks_compare_to_cases" value="true"/> 
     53<setting id="org.eclipse.cdt.core.formatter.insert_space_before_unary_operator" value="do not insert"/> 
     54<setting id="org.eclipse.cdt.core.formatter.insert_space_before_comma_in_declarator_list" value="do not insert"/> 
     55<setting id="org.eclipse.cdt.core.formatter.alignment_for_arguments_in_method_invocation" value="20"/> 
     56<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_while" value="insert"/> 
     57<setting id="org.eclipse.cdt.core.formatter.insert_space_between_empty_brackets" value="do not insert"/> 
     58<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_bracket" value="do not insert"/> 
     59<setting id="org.eclipse.cdt.core.formatter.alignment_for_parameters_in_method_declaration" value="82"/> 
     60<setting id="org.eclipse.cdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer" value="do not insert"/> 
     61<setting id="org.eclipse.cdt.core.formatter.number_of_empty_lines_to_preserve" value="1"/> 
     62<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_method_invocation" value="do not insert"/> 
     63<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_brace_in_array_initializer" value="insert"/> 
     64<setting id="org.eclipse.cdt.core.formatter.insert_space_before_semicolon_in_for" value="do not insert"/> 
     65<setting id="org.eclipse.cdt.core.formatter.brace_position_for_block" value="next_line"/> 
     66<setting id="org.eclipse.cdt.core.formatter.insert_space_before_colon_in_conditional" value="insert"/> 
     67<setting id="org.eclipse.cdt.core.formatter.brace_position_for_type_declaration" value="next_line"/> 
     68<setting id="org.eclipse.cdt.core.formatter.insert_space_before_assignment_operator" value="insert"/> 
     69<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_angle_bracket_in_template_arguments" value="do not insert"/> 
     70<setting id="org.eclipse.cdt.core.formatter.insert_space_before_comma_in_expression_list" value="do not insert"/> 
     71<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_angle_bracket_in_template_parameters" value="do not insert"/> 
     72<setting id="org.eclipse.cdt.core.formatter.continuation_indentation" value="2"/> 
     73<setting id="org.eclipse.cdt.core.formatter.alignment_for_expression_list" value="0"/> 
     74<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_method_declaration" value="do not insert"/> 
     75<setting id="org.eclipse.cdt.core.formatter.insert_space_before_comma_in_template_parameters" value="do not insert"/> 
     76<setting id="org.eclipse.cdt.core.formatter.insert_space_after_binary_operator" value="insert"/> 
     77<setting id="org.eclipse.cdt.core.formatter.insert_space_before_colon_in_default" value="do not insert"/> 
     78<setting id="org.eclipse.cdt.core.formatter.alignment_for_conditional_expression" value="0"/> 
     79<setting id="org.eclipse.cdt.core.formatter.insert_space_between_empty_parens_in_method_invocation" value="do not insert"/> 
     80<setting id="org.eclipse.cdt.core.formatter.insert_space_before_comma_in_array_initializer" value="do not insert"/> 
     81<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_if" value="do not insert"/> 
     82<setting id="org.eclipse.cdt.core.formatter.format_guardian_clause_on_one_line" value="false"/> 
     83<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_cast" value="do not insert"/> 
     84<setting id="org.eclipse.cdt.core.formatter.indent_access_specifier_compare_to_type_header" value="true"/> 
     85<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_type_declaration" value="insert"/> 
     86<setting id="org.eclipse.cdt.core.formatter.insert_space_after_colon_in_labeled_statement" value="insert"/> 
     87<setting id="org.eclipse.cdt.core.formatter.continuation_indentation_for_array_initializer" value="2"/> 
     88<setting id="org.eclipse.cdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters" value="insert"/> 
     89<setting id="org.eclipse.cdt.core.formatter.insert_space_after_semicolon_in_for" value="insert"/> 
     90<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_method_invocation" value="do not insert"/> 
     91<setting id="org.eclipse.cdt.core.formatter.indent_body_declarations_compare_to_namespace_header" value="true"/> 
     92<setting id="org.eclipse.cdt.core.formatter.insert_space_after_closing_brace_in_block" value="insert"/> 
     93<setting id="org.eclipse.cdt.core.formatter.insert_space_after_assignment_operator" value="insert"/> 
     94<setting id="org.eclipse.cdt.core.formatter.alignment_for_compact_if" value="0"/> 
     95<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_array_initializer" value="insert"/> 
     96<setting id="org.eclipse.cdt.core.formatter.insert_new_line_at_end_of_file_if_missing" value="do not insert"/> 
     97<setting id="org.eclipse.cdt.core.formatter.insert_space_after_comma_in_template_parameters" value="insert"/> 
     98<setting id="org.eclipse.cdt.core.formatter.insert_space_after_comma_in_expression_list" value="insert"/> 
     99<setting id="org.eclipse.cdt.core.formatter.insert_space_before_question_in_conditional" value="insert"/> 
     100<setting id="org.eclipse.cdt.core.formatter.insert_space_before_binary_operator" value="insert"/> 
     101<setting id="org.eclipse.cdt.core.formatter.insert_new_line_before_identifier_in_function_declaration" value="do not insert"/> 
     102<setting id="org.eclipse.cdt.core.formatter.alignment_for_base_clause_in_type_declaration" value="82"/> 
     103<setting id="org.eclipse.cdt.core.formatter.insert_space_before_comma_in_method_declaration_throws" value="do not insert"/> 
     104<setting id="org.eclipse.cdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments" value="do not insert"/> 
     105<setting id="org.eclipse.cdt.core.formatter.indent_declaration_compare_to_template_header" value="false"/> 
     106<setting id="org.eclipse.cdt.core.formatter.insert_space_after_unary_operator" value="do not insert"/> 
     107<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_switch" value="insert"/> 
     108<setting id="org.eclipse.cdt.core.formatter.indent_statements_compare_to_body" value="true"/> 
     109<setting id="org.eclipse.cdt.core.formatter.insert_space_after_comma_in_method_declaration_throws" value="insert"/> 
     110<setting id="org.eclipse.cdt.core.formatter.indent_statements_compare_to_block" value="true"/> 
     111<setting id="org.eclipse.cdt.core.formatter.insert_space_before_comma_in_template_arguments" value="do not insert"/> 
     112<setting id="org.eclipse.cdt.core.formatter.insert_new_line_before_catch_in_try_statement" value="insert"/> 
     113<setting id="org.eclipse.cdt.core.formatter.alignment_for_throws_clause_in_method_declaration" value="82"/> 
     114<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_method_invocation" value="do not insert"/> 
     115<setting id="org.eclipse.cdt.core.formatter.insert_space_after_closing_paren_in_cast" value="insert"/> 
     116<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_catch" value="do not insert"/> 
     117<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_angle_bracket_in_template_parameters" value="do not insert"/> 
     118<setting id="org.eclipse.cdt.core.formatter.tabulation.char" value="tab"/> 
     119<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_angle_bracket_in_template_parameters" value="do not insert"/> 
     120<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_while" value="do not insert"/> 
    58121<setting id="org.eclipse.cdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments" value="insert"/> 
    59 <setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_while" value="do not insert"/> 
    60122<setting id="org.eclipse.cdt.core.formatter.brace_position_for_block_in_case" value="next_line"/> 
    61 <setting id="org.eclipse.cdt.core.formatter.insert_space_after_question_in_conditional" value="insert"/> 
    62123<setting id="org.eclipse.cdt.core.formatter.compact_else_if" value="true"/> 
    63 <setting id="org.eclipse.cdt.core.formatter.insert_space_before_semicolon" value="do not insert"/> 
     124<setting id="org.eclipse.cdt.core.formatter.insert_space_after_postfix_operator" value="do not insert"/> 
     125<setting id="org.eclipse.cdt.core.formatter.insert_space_after_colon_in_base_clause" value="insert"/> 
     126<setting id="org.eclipse.cdt.core.formatter.insert_new_line_after_template_declaration" value="do not insert"/> 
     127<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_catch" value="do not insert"/> 
    64128<setting id="org.eclipse.cdt.core.formatter.keep_then_statement_on_same_line" value="false"/> 
    65129<setting id="org.eclipse.cdt.core.formatter.brace_position_for_switch" value="next_line"/> 
    66 <setting id="org.eclipse.cdt.core.formatter.indent_breaks_compare_to_cases" value="true"/> 
    67 <setting id="org.eclipse.cdt.core.formatter.alignment_for_arguments_in_method_invocation" value="84"/> 
    68 <setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_while" value="insert"/> 
    69130<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_if" value="insert"/> 
    70131<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_switch" value="do not insert"/> 
    71 <setting id="org.eclipse.cdt.core.formatter.alignment_for_parameters_in_method_declaration" value="84"/> 
    72132<setting id="org.eclipse.cdt.core.formatter.keep_imple_if_on_one_line" value="false"/> 
    73133<setting id="org.eclipse.cdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer" value="do not insert"/> 
    74134<setting id="org.eclipse.cdt.core.formatter.indentation.size" value="4"/> 
    75 <setting id="org.eclipse.cdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer" value="do not insert"/> 
    76135<setting id="org.eclipse.cdt.core.formatter.brace_position_for_namespace_declaration" value="next_line"/> 
    77136<setting id="org.eclipse.cdt.core.formatter.insert_space_after_colon_in_conditional" value="insert"/> 
    78 <setting id="org.eclipse.cdt.core.formatter.number_of_empty_lines_to_preserve" value="1"/> 
     137<setting id="org.eclipse.cdt.core.formatter.insert_space_before_comma_in_enum_declarations" value="do not insert"/> 
     138<setting id="org.eclipse.cdt.core.formatter.insert_space_after_prefix_operator" value="do not insert"/> 
     139<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_angle_bracket_in_template_arguments" value="do not insert"/> 
    79140<setting id="org.eclipse.cdt.core.formatter.brace_position_for_array_initializer" value="end_of_line"/> 
    80141<setting id="org.eclipse.cdt.core.formatter.insert_space_before_colon_in_case" value="do not insert"/> 
     142<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_catch" value="insert"/> 
    81143<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_namespace_declaration" value="insert"/> 
    82 <setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_method_invocation" value="do not insert"/> 
    83 <setting id="org.eclipse.cdt.core.formatter.insert_new_line_before_while_in_do_statement" value="do not insert"/> 
    84 <setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_brace_in_array_initializer" value="insert"/> 
     144<setting id="org.eclipse.cdt.core.formatter.insert_space_before_postfix_operator" value="do not insert"/> 
     145<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_bracket" value="do not insert"/> 
     146<setting id="org.eclipse.cdt.core.formatter.insert_new_line_before_while_in_do_statement" value="insert"/> 
    85147<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_for" value="insert"/> 
    86 <setting id="org.eclipse.cdt.core.formatter.insert_space_before_semicolon_in_for" value="do not insert"/> 
    87 <setting id="org.eclipse.cdt.core.formatter.insert_space_before_colon_in_conditional" value="insert"/> 
    88 <setting id="org.eclipse.cdt.core.formatter.brace_position_for_block" value="next_line"/> 
    89 <setting id="org.eclipse.cdt.core.formatter.brace_position_for_type_declaration" value="next_line"/> 
     148<setting id="org.eclipse.cdt.core.formatter.insert_space_after_closing_angle_bracket_in_template_parameters" value="insert"/> 
     149<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_angle_bracket_in_template_arguments" value="do not insert"/> 
    90150</profile> 
    91151</profiles> 
  • trunk/include/libdodo/ioNetworkHttp.h

    r873 r874  
    143143                                         */ 
    144144                                        virtual ~http(); 
    145                                  
     145 
    146146#ifdef OPENSSL_EXT 
    147147 
    148148                                        /** 
    149149                                         * set certificates information 
    150                                          * @param certs defines certificates information  
     150                                         * @param certs defines certificates information 
    151151                                         */ 
    152152                                        virtual void setSertificates(const ssl::__certificates &certs); 
    153153 
    154154                                        /** 
    155                                          * remove certificates information  
     155                                         * remove certificates information 
    156156                                         */ 
    157157                                        virtual void removeSertificates(); 
     
    168168                                        /** 
    169169                                         * @param url defines Url 
     170                                         * @note authentification may be as a part of URL or defined by setHttpAuthentification method 
    170171                                         */ 
    171172                                        virtual void setUrl(const dodoString &url); 
     
    194195                                         * @return server response 
    195196                                         * @param url defines Url 
     197                                         * @note authentification may be as a part of URL or defined by setHttpAuthentification method 
    196198                                         */ 
    197199                                        virtual __httpResponse GET(const dodoString &url); 
     
    208210                                         * @param data defines POST data 
    209211                                         * @param type defines content type of the POST request 
     212                                         * @note authentification may be as a part of URL or defined by setHttpAuthentification method 
    210213                                         */ 
    211214                                        virtual __httpResponse POST(const dodoString &url, const dodoString &data, const dodoString &type); 
     
    223226                                         * @param url defines Url 
    224227                                         * @param arguments defines request arguments 
     228                                         * @note authentification may be as a part of URL or defined by setHttpAuthentification method 
    225229                                         */ 
    226230                                        virtual __httpResponse POST(const dodoString &url, const dodoStringMap &arguments); 
     
    238242                                         * @param arguments defines request arguments 
    239243                                         * @param files defines path to files 
     244                                         * @note authentification may be as a part of URL or defined by setHttpAuthentification method 
    240245                                         */ 
    241246                                        virtual __httpResponse POST(const dodoString &url, const dodoStringMap &arguments, const dodoStringMap &files); 
     
    247252                                         */ 
    248253                                        virtual void POST(const dodoStringMap &arguments, const dodoStringMap &files); 
     254 
     255                                        /** 
     256                                         * set HTTP authentification information 
     257                                         * @param user defines user name for HTTP authentification 
     258                                         * @param password defines password for HTTP authentification 
     259                                         */ 
     260                                        virtual void setAuthInfo(const dodoString &user, const dodoString &password); 
    249261 
    250262                                        bool followRedirection;                     ///< if true follow the `Location` header; true by default 
  • trunk/src/ioNetworkHttp.cc

    r873 r874  
    8888                           authTries(0), 
    8989                           scheme(SCHEME_HTTP) 
    90                             
     90 
    9191#ifdef OPENSSL_EXT 
    92                             
     92 
    9393                           , 
    9494                           certsSet(false) 
    95                             
     95 
    9696#endif 
    9797{ 
     
    117117#ifdef OPENSSL_EXT 
    118118 
    119 void  
     119void 
    120120http::setSertificates(const ssl::__certificates &a_certs) 
    121121{ 
    122122        certs = a_certs; 
    123          
     123 
    124124        certsSet = true; 
    125125} 
     
    127127//------------------------------------------------------------------- 
    128128 
    129 void  
     129void 
    130130http::removeSertificates() 
    131131{ 
    132132        certs = ssl::__certificates(); 
    133          
     133 
    134134        certsSet = false; 
    135135} 
     
    187187 
    188188        } 
    189          
     189 
    190190        urlBasePath.clear(); 
    191191        urlQuery.clear(); 
     
    244244 
    245245        dodoString data; 
    246          
    247         if (scheme == SCHEME_HTTP) 
    248         { 
    249                 net = new client(OPTIONS_PROTO_FAMILY_IPV4, OPTIONS_TRANSFER_TYPE_STREAM); 
    250                 ex = new exchange; 
    251         } 
    252  
    253 #ifdef OPENSSL_EXT 
    254  
    255         else 
    256         { 
    257                 net = new ssl::client(OPTIONS_PROTO_FAMILY_IPV4, OPTIONS_TRANSFER_TYPE_STREAM); 
    258                 ex = new ssl::exchange; 
    259         } 
    260  
    261 #endif 
    262  
    263         if (proxyAuthInfo.enabled) 
    264         { 
    265                 if (scheme == SCHEME_HTTP) 
    266                         net->connect(proxyAuthInfo.host, proxyAuthInfo.port, *ex); 
    267  
    268 #ifdef OPENSSL_EXT 
    269  
    270                         else 
    271                         {        
    272                                 net->connect(proxyAuthInfo.host, proxyAuthInfo.port, *(exchange *)ex); 
    273                                 data.append("CONNECT "); 
    274                                 data.append(urlComponents.host); 
    275                                 data.append(":"); 
    276                                 data.append(urlComponents.port); 
    277                                 data.append(" HTTP/1.0\r\n"); 
    278                                 if (requestHeaders.find(HTTP_REQUESTHEADER_PROXYAUTHORIZATION) != requestHeaders.end()) 
    279                                 { 
    280                                         data.append(requestHeaderStatements[HTTP_REQUESTHEADER_PROXYAUTHORIZATION]); 
    281                                         data.append(": "); 
    282                                         data.append(requestHeaders[HTTP_REQUESTHEADER_PROXYAUTHORIZATION]); 
    283                                         data.append("\r\n"); 
    284                                 } 
    285                                 data.append("\r\n"); 
    286                                  
    287                                 ex->outSize = data.size(); 
    288                                 ex->exchange::_write(data.c_str()); 
    289                                  
    290                                 char proxyData[512]; 
    291                                 ex->setInBufferSize(512); 
    292                                 ex->inSize = 512; 
    293  
    294                                 try 
    295                                 { 
    296                                         switch (getProxyConnectResponse(proxyData, ex)) 
    297                                         { 
    298                                                 case GETCONTENTSTATUS_NORMAL: 
    299  
    300                                                         break; 
    301  
    302                                                 case GETCONTENTSTATUS_PROXYBASICAUTH: 
    303                                                          
    304                                                         if (authTries > 2) 
    305                                                         { 
    306                                                                 authTries = 0; 
    307  
    308                                                                 throw baseEx(ERRMODULE_IONETWORKHTTP, HTTPEX_GET, ERR_LIBDODO, HTTPEX_NOTAUTHORIZED, IONETWORKHTTPEX_NOTAUTHORIZED_STR, __LINE__, __FILE__); 
    309                                                         } 
    310  
    311                                                         makeBasicAuth(HTTP_REQUESTHEADER_PROXYAUTHORIZATION, proxyAuthInfo.user, proxyAuthInfo.password); 
    312  
    313                                                         delete ex; 
    314                                                         delete net; 
    315                                                         ex = NULL; 
    316                                                         net = NULL; 
    317                                  
    318                                                         GET(); 
    319                                                          
    320                                                         clear(); 
    321  
    322                                                         return; 
    323  
    324                                                 case GETCONTENTSTATUS_PROXYDIGESTAUTH: 
    325  
    326                                                         if (authTries > 2) 
    327                                                         { 
    328                                                                 authTries = 0; 
    329  
    330                                                                 throw baseEx(ERRMODULE_IONETWORKHTTP, HTTPEX_GET, ERR_LIBDODO, HTTPEX_NOTAUTHORIZED, IONETWORKHTTPEX_NOTAUTHORIZED_STR, __LINE__, __FILE__); 
    331                                                         } 
    332  
    333                                                         makeDigestAuth(HTTP_RESPONSEHEADER_PROXYAUTHENTICATE, HTTP_REQUESTHEADER_PROXYAUTHORIZATION, "GET", proxyAuthInfo.user, proxyAuthInfo.password); 
    334  
    335                                                         delete ex; 
    336                                                         delete net; 
    337                                                         ex = NULL; 
    338                                                         net = NULL; 
    339                                  
    340                                                         GET(); 
    341                                                          
    342                                                         clear(); 
    343  
    344                                                         return; 
    345                                         } 
    346                                 } 
    347                                 catch (...) 
    348                                 { 
    349                                         delete ex; 
    350                                         delete net; 
    351  
    352                                         clear(); 
    353  
    354                                         throw; 
    355                                 } 
    356                                  
    357                                 if (certsSet) 
    358                                         ((ssl::client *)net)->setSertificates(certs); 
    359                                 else     
    360                                         ((ssl::client *)net)->initSsl(); 
    361                          
    362                                 ((ssl::client *)net)->socket = ((ssl::exchange *)ex)->socket;  
    363                                 ((ssl::client *)net)->connectSsl(); 
    364   
    365                                 ((ssl::exchange *)ex)->sslHandle = ((ssl::client *)net)->sslHandle; 
    366  
    367                                 ((ssl::client *)net)->socket = -1; 
    368                                 ((ssl::client *)net)->sslHandle = NULL; 
    369                         } 
    370 #endif           
    371         } 
    372         else 
    373         { 
    374                 tools::__hostInfo host = tools::network::getHostInfo(urlComponents.host); 
    375  
    376                 dodoStringArray::iterator o = host.addresses.begin(), p = host.addresses.end(); 
    377                 for (; o != p; ++o) 
    378                         try 
    379                         { 
    380                                 if (scheme == SCHEME_HTTP) 
    381                                 { 
    382                                         net->connect(*o, tools::string::stringToI(urlComponents.port), *ex); 
    383                                         ex->setInBufferSize(512); 
    384                                         ex->inSize = 512; 
    385                                 } 
    386  
    387 #ifdef OPENSSL_EXT 
    388  
    389                                 else 
    390                                 { 
    391                                         if (certsSet) 
    392                                                 ((ssl::client *)net)->setSertificates(certs); 
    393                                          
    394                                         ((ssl::client *)net)->connect(*o, tools::string::stringToI(urlComponents.port), *(ssl::exchange *)ex); 
    395                                         ex->setInBufferSize(512); 
    396                                         ex->inSize = 512; 
    397                                 } 
    398                                  
    399 #endif 
    400  
    401                                 break; 
    402                         } 
    403                         catch (baseEx &exp) 
    404                         { 
    405 #ifdef OPENSSL_EXT 
    406  
    407                                 if (exp.funcID == CLIENTEX_CONNECT || exp.funcID == ssl::CLIENTEX_CONNECT) 
    408  
    409 #else 
    410  
    411                                 if (exp.funcID == CLIENTEX_CONNECT) 
    412  
    413 #endif 
    414                                 { 
    415                                         if ((o + 1) == p) 
    416                                         { 
    417                                                 delete net; 
    418                                                 delete ex; 
    419  
    420                                                 throw baseEx(ERRMODULE_IONETWORKHTTP, HTTPEX_GET, ERR_LIBDODO, HTTPEX_CANNOTCONNECT, IONETWORKHTTPEX_CANNOTCONNECT_STR, __LINE__, __FILE__); 
    421                                         } 
    422                                         else 
    423                                                 continue; 
    424                                 } 
    425  
    426                                 delete net; 
    427                                 delete ex; 
    428  
    429                                 throw; 
    430                         } 
    431         } 
    432  
    433         delete net; 
    434  
    435         data.clear(); 
    436          
    437         data.append("GET "); 
    438         data.append(urlBasePath); 
    439         data.append(urlQuery); 
    440         if (proxyAuthInfo.enabled) 
    441                 data.append(" HTTP/1.1\r\n"); 
    442         else 
    443                 data.append(" HTTP/1.0\r\n"); 
    444          
    445         if (cacheAuthentification) 
    446         { 
    447                 dodoStringMap::iterator header = httpAuth.find(urlBasePath); 
    448                 if (header != httpAuth.end()) 
    449                         requestHeaders[HTTP_REQUESTHEADER_AUTHORIZATION] = header->second; 
    450         } 
    451  
    452         dodoMap<short, dodoString>::iterator i(requestHeaders.begin()), j(requestHeaders.end()); 
    453         for (; i != j; ++i) 
    454         { 
    455 #ifdef OPENSSL_EXT 
    456  
    457                 if (proxyAuthInfo.enabled && scheme == SCHEME_HTTPS && i->first == HTTP_REQUESTHEADER_PROXYAUTHORIZATION) 
    458                         continue; 
    459  
    460 #endif 
    461  
    462                 data.append(requestHeaderStatements[i->first]); 
    463                 data.append(": "); 
    464                 data.append(i->second); 
    465                 data.append("\r\n"); 
    466         } 
    467         data.append("Host: "); 
    468         data.append(urlComponents.host); 
    469  
    470         data.append("\r\n\r\n"); 
    471  
    472         ex->writeStreamString(data); 
    473  
    474         try 
    475         { 
    476                 switch (getContent(data, ex)) 
    477                 { 
    478                         case GETCONTENTSTATUS_NORMAL: 
    479  
    480                                 break; 
    481  
    482                         case GETCONTENTSTATUS_REDIRECT: 
    483  
    484                                 setUrl(response.headers[HTTP_RESPONSEHEADER_LOCATION]); 
    485  
    486                                 GET(); 
    487  
    488                                 break; 
    489  
    490                         case GETCONTENTSTATUS_PROXYBASICAUTH: 
    491  
    492                                 if (authTries > 2) 
    493                                 { 
    494                                         authTries = 0; 
    495  
    496                                         throw baseEx(ERRMODULE_IONETWORKHTTP, HTTPEX_GET, ERR_LIBDODO, HTTPEX_NOTAUTHORIZED, IONETWORKHTTPEX_NOTAUTHORIZED_STR, __LINE__, __FILE__); 
    497                                 } 
    498  
    499                                 makeBasicAuth(HTTP_REQUESTHEADER_PROXYAUTHORIZATION, proxyAuthInfo.user, proxyAuthInfo.password); 
    500  
    501                                 GET(); 
    502  
    503                                 break; 
    504  
    505                         case GETCONTENTSTATUS_WWWBASICAUTH: 
    506  
    507                                 if (authTries > 2) 
    508                                 { 
    509                                         authTries = 0; 
    510  
    511                                         throw baseEx(ERRMODULE_IONETWORKHTTP, HTTPEX_GET, ERR_LIBDODO, HTTPEX_NOTAUTHORIZED, IONETWORKHTTPEX_NOTAUTHORIZED_STR, __LINE__, __FILE__); 
    512                                 } 
    513  
    514                                 makeBasicAuth(HTTP_REQUESTHEADER_AUTHORIZATION, urlComponents.login, urlComponents.password); 
    515  
    516                                 GET(); 
    517  
    518                                 break; 
    519  
    520                         case GETCONTENTSTATUS_PROXYDIGESTAUTH: 
    521  
    522                                 if (authTries > 2) 
    523                                 { 
    524                                         authTries = 0; 
    525  
    526                                         throw baseEx(ERRMODULE_IONETWORKHTTP, HTTPEX_GET, ERR_LIBDODO, HTTPEX_NOTAUTHORIZED, IONETWORKHTTPEX_NOTAUTHORIZED_STR, __LINE__, __FILE__); 
    527                                 } 
    528  
    529                                 makeDigestAuth(HTTP_RESPONSEHEADER_PROXYAUTHENTICATE, HTTP_REQUESTHEADER_PROXYAUTHORIZATION, "GET", proxyAuthInfo.user, proxyAuthInfo.password); 
    530  
    531                                 GET(); 
    532  
    533                                 break; 
    534  
    535                         case GETCONTENTSTATUS_WWWDIGESTAUTH: 
    536  
    537                                 if (authTries > 2) 
    538                                 { 
    539                                         authTries = 0; 
    540  
    541                                         throw baseEx(ERRMODULE_IONETWORKHTTP, HTTPEX_GET, ERR_LIBDODO, HTTPEX_NOTAUTHORIZED, IONETWORKHTTPEX_NOTAUTHORIZED_STR, __LINE__, __FILE__); 
    542                                 } 
    543  
    544                                 makeDigestAuth(HTTP_RESPONSEHEADER_WWWAUTHENTICATE, HTTP_REQUESTHEADER_AUTHORIZATION, "GET", urlComponents.login, urlComponents.password); 
    545  
    546                                 GET(); 
    547  
    548                                 break; 
    549  
    550                         case GETCONTENTSTATUS_WWWPROXYBASICAUTH: 
    551  
    552                                 if (authTries > 2) 
    553                                 { 
    554                                         authTries = 0; 
    555  
    556                                         throw baseEx(ERRMODULE_IONETWORKHTTP, HTTPEX_GET, ERR_LIBDODO, HTTPEX_NOTAUTHORIZED, IONETWORKHTTPEX_NOTAUTHORIZED_STR, __LINE__, __FILE__); 
    557                                 } 
    558  
    559                                 makeBasicAuth(HTTP_REQUESTHEADER_AUTHORIZATION, urlComponents.login, urlComponents.password); 
    560  
    561                                 if (proxyAuthInfo.authType == PROXYAUTHTYPE_BASIC) 
    562                                         makeBasicAuth(HTTP_REQUESTHEADER_PROXYAUTHORIZATION, proxyAuthInfo.user, proxyAuthInfo.password); 
    563                                 else 
    564                                         makeDigestAuth(HTTP_RESPONSEHEADER_PROXYAUTHENTICATE, HTTP_REQUESTHEADER_PROXYAUTHORIZATION, "GET", proxyAuthInfo.user, proxyAuthInfo.password); 
    565  
    566                                 GET(); 
    567  
    568                                 break; 
    569  
    570                         case GETCONTENTSTATUS_WWWPROXYDIGESTAUTH: 
    571  
    572                                 if (authTries > 2) 
    573                                 { 
    574                                         authTries = 0; 
    575  
    576                                         throw baseEx(ERRMODULE_IONETWORKHTTP, HTTPEX_GET, ERR_LIBDODO, HTTPEX_NOTAUTHORIZED, IONETWORKHTTPEX_NOTAUTHORIZED_STR, __LINE__, __FILE__); 
    577                                 } 
    578  
    579                                 makeDigestAuth(HTTP_RESPONSEHEADER_WWWAUTHENTICATE, HTTP_REQUESTHEADER_AUTHORIZATION, "GET", urlComponents.login, urlComponents.password); 
    580  
    581                                 if (proxyAuthInfo.authType == PROXYAUTHTYPE_BASIC) 
    582                                         makeBasicAuth(HTTP_REQUESTHEADER_PROXYAUTHORIZATION, proxyAuthInfo.user, proxyAuthInfo.password); 
    583                                 else 
    584                                         makeDigestAuth(HTTP_RESPONSEHEADER_PROXYAUTHENTICATE, HTTP_REQUESTHEADER_PROXYAUTHORIZATION, "GET", proxyAuthInfo.user, proxyAuthInfo.password); 
    585  
    586                                 GET(); 
    587  
    588                                 break; 
    589                 } 
    590         } 
    591         catch (...) 
    592         { 
    593                 delete ex; 
    594  
    595                 clear(); 
    596  
    597                 throw; 
    598         } 
    599  
    600         delete ex; 
    601  
    602         clear(); 
    603 } 
    604  
    605 //------------------------------------------------------------------- 
    606  
    607 __httpResponse 
    608 http::GET(const dodoString &a_url) 
    609 { 
    610         setUrl(a_url); 
    611  
    612         GET(); 
    613  
    614         return response; 
    615 } 
    616  
    617 //------------------------------------------------------------------- 
    618  
    619 __httpResponse 
    620 http::POST(const dodoString &a_url, 
    621                    const dodoStringMap &arguments, 
    622                    const dodoStringMap &files) 
    623 { 
    624         setUrl(a_url); 
    625  
    626         POST(arguments, files); 
    627  
    628         return response; 
    629 } 
    630  
    631 //------------------------------------------------------------------- 
    632  
    633 void 
    634 http::POST(const dodoStringMap &arguments, 
    635                    const dodoStringMap &files) 
    636 { 
    637         dodoString boundary = "---------------------------" + tools::string::ulToString(tools::misc::ulRandom()) + tools::string::ulToString(tools::misc::ulRandom()); 
    638         dodoString type = "multipart/form-data; boundary=" + boundary; 
    639         boundary.insert(0, "--"); 
    640  
    641         dodoString data; 
    642  
    643         dodoStringMap::const_iterator i = files.begin(), j = files.end(); 
    644  
    645         for (; i != j; ++i) 
    646         { 
    647                 data.append(boundary); 
    648                 data.append("\r\nContent-Disposition: form-data; name=\""); 
    649                 data.append(i->first); 
    650                 data.append("\"; filename=\""); 
    651                 data.append(tools::filesystem::basename(i->second)); 
    652                 data.append("\"\r\n"); 
    653  
    654                 data.append("Content-Type: application/octet-stream\r\n\r\n"); 
    655  
    656                 data.append(tools::filesystem::getFileContents(i->second)); 
    657                 data.append("\r\n"); 
    658         } 
    659  
    660         i = arguments.begin(); 
    661         j = arguments.end(); 
    662         for (; i != j; ++i) 
    663         { 
    664                 data.append(boundary); 
    665                 data.append("\r\nContent-Disposition: form-data; name=\""); 
    666                 data.append(i->first); 
    667                 data.append("\"\r\n\r\n"); 
    668  
    669                 data.append(i->second); 
    670                 data.append("\r\n"); 
    671         } 
    672         data.append(boundary); 
    673         data.append("--"); 
    674  
    675         POST(data, type); 
    676 } 
    677  
    678 //------------------------------------------------------------------- 
    679  
    680 __httpResponse 
    681 http::POST(const dodoString &a_url, 
    682                    const dodoStringMap &arguments) 
    683 { 
    684         setUrl(a_url); 
    685  
    686         POST(arguments); 
    687  
    688         return response; 
    689 } 
    690  
    691 //------------------------------------------------------------------- 
    692  
    693 void 
    694 http::POST(const dodoStringMap &arguments) 
    695 { 
    696         dodoString data; 
    697  
    698         dodoStringMap::const_iterator i(arguments.begin()), j(arguments.end()); 
    699         --j; 
    700  
    701         for (; i != j; ++i) 
    702         { 
    703                 data.append(tools::misc::encodeUrl(i->first)); 
    704                 data.append("="); 
    705                 data.append(tools::misc::encodeUrl(i->second)); 
    706                 data.append("&"); 
    707         } 
    708         data.append(tools::misc::encodeUrl(i->first)); 
    709         data.append("="); 
    710         data.append(tools::misc::encodeUrl(i->second)); 
    711  
    712         POST(data, "application/x-www-form-urlencoded"); 
    713 } 
    714  
    715 //------------------------------------------------------------------- 
    716  
    717 __httpResponse 
    718 http::POST(const dodoString &a_url, 
    719                    const dodoString &data, 
    720                    const dodoString &type) 
    721 { 
    722         setUrl(a_url); 
    723  
    724         POST(data, type); 
    725  
    726         return response; 
    727 } 
    728  
    729 //------------------------------------------------------------------- 
    730  
    731 void 
    732 http::POST(const dodoString &a_data, 
    733                    const dodoString &type) 
    734 { 
    735         response = __httpResponse(); 
    736  
    737         exchange *ex; 
    738         client *net; 
    739  
    740         dodoString data; 
    741          
     246 
    742247        if (scheme == SCHEME_HTTP) 
    743248        { 
     
    779284                                } 
    780285                                data.append("\r\n"); 
    781                                  
     286 
    782287                                ex->outSize = data.size(); 
    783288                                ex->exchange::_write(data.c_str()); 
     
    801306                                                                authTries = 0; 
    802307 
    803                                                                 throw baseEx(ERRMODULE_IONETWORKHTTP, HTTPEX_POST, ERR_LIBDODO, HTTPEX_NOTAUTHORIZED, IONETWORKHTTPEX_NOTAUTHORIZED_STR, __LINE__, __FILE__); 
     308                                                                throw baseEx(ERRMODULE_IONETWORKHTTP, HTTPEX_GET, ERR_LIBDODO, HTTPEX_NOTAUTHORIZED, IONETWORKHTTPEX_NOTAUTHORIZED_STR, __LINE__, __FILE__); 
    804309                                                        } 
    805310 
     
    810315                                                        ex = NULL; 
    811316                                                        net = NULL; 
    812                                  
    813                                                         POST(data, type); 
    814                                                          
     317 
     318                                                        GET(); 
     319 
    815320                                                        clear(); 
    816321 
     
    823328                                                                authTries = 0; 
    824329 
    825                                                                 throw baseEx(ERRMODULE_IONETWORKHTTP, HTTPEX_POST, ERR_LIBDODO, HTTPEX_NOTAUTHORIZED, IONETWORKHTTPEX_NOTAUTHORIZED_STR, __LINE__, __FILE__); 
     330                                                                throw baseEx(ERRMODULE_IONETWORKHTTP, HTTPEX_GET, ERR_LIBDODO, HTTPEX_NOTAUTHORIZED, IONETWORKHTTPEX_NOTAUTHORIZED_STR, __LINE__, __FILE__); 
    826331                                                        } 
    827332 
    828                                                         makeDigestAuth(HTTP_RESPONSEHEADER_PROXYAUTHENTICATE, HTTP_REQUESTHEADER_PROXYAUTHORIZATION, "POST", proxyAuthInfo.user, proxyAuthInfo.password); 
     333                                                        makeDigestAuth(HTTP_RESPONSEHEADER_PROXYAUTHENTICATE, HTTP_REQUESTHEADER_PROXYAUTHORIZATION, "GET", proxyAuthInfo.user, proxyAuthInfo.password); 
    829334 
    830335                                                        delete ex; 
     
    832337                                                        ex = NULL; 
    833338                                                        net = NULL; 
    834                                  
    835                                                         POST(data, type); 
     339 
     340                                                        GET(); 
    836341 
    837342                                                        clear(); 
     
    844349                                        delete ex; 
    845350                                        delete net; 
    846                                  
     351 
    847352                                        clear(); 
    848353 
    849354                                        throw; 
    850355                                } 
    851                                  
     356 
    852357                                if (certsSet) 
    853358                                        ((ssl::client *)net)->setSertificates(certs); 
    854                                 else     
     359                                else 
    855360                                        ((ssl::client *)net)->initSsl(); 
    856                                  
    857                                 ((ssl::client *)net)->socket = ((ssl::exchange *)ex)->socket;  
     361 
     362                                ((ssl::client *)net)->socket = ((ssl::exchange *)ex)->socket; 
    858363                                ((ssl::client *)net)->connectSsl(); 
    859   
     364 
    860365                                ((ssl::exchange *)ex)->sslHandle = ((ssl::client *)net)->sslHandle; 
    861366 
     
    863368                                ((ssl::client *)net)->sslHandle = NULL; 
    864369                        } 
    865  
    866 #endif           
     370#endif 
    867371        } 
    868372        else 
     
    887391                                        if (certsSet) 
    888392                                                ((ssl::client *)net)->setSertificates(certs); 
    889                                          
     393 
    890394                                        ((ssl::client *)net)->connect(*o, tools::string::stringToI(urlComponents.port), *(ssl::exchange *)ex); 
    891395                                        ex->setInBufferSize(512); 
     
    914418                                                delete ex; 
    915419 
     420                                                throw baseEx(ERRMODULE_IONETWORKHTTP, HTTPEX_GET, ERR_LIBDODO, HTTPEX_CANNOTCONNECT, IONETWORKHTTPEX_CANNOTCONNECT_STR, __LINE__, __FILE__); 
     421                                        } 
     422                                        else 
     423                                                continue; 
     424                                } 
     425 
     426                                delete net; 
     427                                delete ex; 
     428 
     429                                throw; 
     430                        } 
     431        } 
     432 
     433        delete net; 
     434 
     435        data.clear(); 
     436 
     437        data.append("GET "); 
     438        data.append(urlBasePath); 
     439        data.append(urlQuery); 
     440        if (proxyAuthInfo.enabled) 
     441                data.append(" HTTP/1.1\r\n"); 
     442        else 
     443                data.append(" HTTP/1.0\r\n"); 
     444 
     445        if (cacheAuthentification) 
     446        { 
     447                dodoStringMap::iterator header = httpAuth.find(urlBasePath); 
     448                if (header != httpAuth.end()) 
     449                        requestHeaders[HTTP_REQUESTHEADER_AUTHORIZATION] = header->second; 
     450        } 
     451 
     452        dodoMap<short, dodoString>::iterator i(requestHeaders.begin()), j(requestHeaders.end()); 
     453        for (; i != j; ++i) 
     454        { 
     455#ifdef OPENSSL_EXT 
     456 
     457                if (proxyAuthInfo.enabled && scheme == SCHEME_HTTPS && i->first == HTTP_REQUESTHEADER_PROXYAUTHORIZATION) 
     458                        continue; 
     459 
     460#endif 
     461 
     462                data.append(requestHeaderStatements[i->first]); 
     463                data.append(": "); 
     464                data.append(i->second); 
     465                data.append("\r\n"); 
     466        } 
     467        data.append("Host: "); 
     468        data.append(urlComponents.host); 
     469 
     470        data.append("\r\n\r\n"); 
     471 
     472        ex->writeStreamString(data); 
     473 
     474        try 
     475        { 
     476                switch (getContent(data, ex)) 
     477                { 
     478                        case GETCONTENTSTATUS_NORMAL: 
     479 
     480                                break; 
     481 
     482                        case GETCONTENTSTATUS_REDIRECT: 
     483 
     484                                setUrl(response.headers[HTTP_RESPONSEHEADER_LOCATION]); 
     485 
     486                                GET(); 
     487 
     488                                break; 
     489 
     490                        case GETCONTENTSTATUS_PROXYBASICAUTH: 
     491 
     492                                if (authTries > 2) 
     493                                { 
     494                                        authTries = 0; 
     495 
     496                                        throw baseEx(ERRMODULE_IONETWORKHTTP, HTTPEX_GET, ERR_LIBDODO, HTTPEX_NOTAUTHORIZED, IONETWORKHTTPEX_NOTAUTHORIZED_STR, __LINE__, __FILE__); 
     497                                } 
     498 
     499                                makeBasicAuth(HTTP_REQUESTHEADER_PROXYAUTHORIZATION, proxyAuthInfo.user, proxyAuthInfo.password); 
     500 
     501                                GET(); 
     502 
     503                                break; 
     504 
     505                        case GETCONTENTSTATUS_WWWBASICAUTH: 
     506 
     507                                if (authTries > 2) 
     508                                { 
     509                                        authTries = 0; 
     510 
     511                                        throw baseEx(ERRMODULE_IONETWORKHTTP, HTTPEX_GET, ERR_LIBDODO, HTTPEX_NOTAUTHORIZED, IONETWORKHTTPEX_NOTAUTHORIZED_STR, __LINE__, __FILE__); 
     512                                } 
     513 
     514                                makeBasicAuth(HTTP_REQUESTHEADER_AUTHORIZATION, urlComponents.login, urlComponents.password); 
     515 
     516                                GET(); 
     517 
     518                                break; 
     519 
     520                        case GETCONTENTSTATUS_PROXYDIGESTAUTH: 
     521 
     522                                if (authTries > 2) 
     523                                { 
     524                                        authTries = 0; 
     525 
     526                                        throw baseEx(ERRMODULE_IONETWORKHTTP, HTTPEX_GET, ERR_LIBDODO, HTTPEX_NOTAUTHORIZED, IONETWORKHTTPEX_NOTAUTHORIZED_STR, __LINE__, __FILE__); 
     527                                } 
     528 
     529                                makeDigestAuth(HTTP_RESPONSEHEADER_PROXYAUTHENTICATE, HTTP_REQUESTHEADER_PROXYAUTHORIZATION, "GET", proxyAuthInfo.user, proxyAuthInfo.password); 
     530 
     531                                GET(); 
     532 
     533                                break; 
     534 
     535                        case GETCONTENTSTATUS_WWWDIGESTAUTH: 
     536 
     537                                if (authTries > 2) 
     538                                { 
     539                                        authTries = 0; 
     540 
     541                                        throw baseEx(ERRMODULE_IONETWORKHTTP, HTTPEX_GET, ERR_LIBDODO, HTTPEX_NOTAUTHORIZED, IONETWORKHTTPEX_NOTAUTHORIZED_STR, __LINE__, __FILE__); 
     542                                } 
     543 
     544                                makeDigestAuth(HTTP_RESPONSEHEADER_WWWAUTHENTICATE, HTTP_REQUESTHEADER_AUTHORIZATION, "GET", urlComponents.login, urlComponents.password); 
     545 
     546                                GET(); 
     547 
     548                                break; 
     549 
     550                        case GETCONTENTSTATUS_WWWPROXYBASICAUTH: 
     551 
     552                                if (authTries > 2) 
     553                                { 
     554                                        authTries = 0; 
     555 
     556                                        throw baseEx(ERRMODULE_IONETWORKHTTP, HTTPEX_GET, ERR_LIBDODO, HTTPEX_NOTAUTHORIZED, IONETWORKHTTPEX_NOTAUTHORIZED_STR, __LINE__, __FILE__); 
     557                                } 
     558 
     559                                makeBasicAuth(HTTP_REQUESTHEADER_AUTHORIZATION, urlComponents.login, urlComponents.password); 
     560 
     561                                if (proxyAuthInfo.authType == PROXYAUTHTYPE_BASIC) 
     562                                        makeBasicAuth(HTTP_REQUESTHEADER_PROXYAUTHORIZATION, proxyAuthInfo.user, proxyAuthInfo.password); 
     563                                else 
     564                                        makeDigestAuth(HTTP_RESPONSEHEADER_PROXYAUTHENTICATE, HTTP_REQUESTHEADER_PROXYAUTHORIZATION, "GET", proxyAuthInfo.user, proxyAuthInfo.password); 
     565 
     566                                GET(); 
     567 
     568                                break; 
     569 
     570                        case GETCONTENTSTATUS_WWWPROXYDIGESTAUTH: 
     571 
     572                                if (authTries > 2) 
     573                                { 
     574                                        authTries = 0; 
     575 
     576                                        throw baseEx(ERRMODULE_IONETWORKHTTP, HTTPEX_GET, ERR_LIBDODO, HTTPEX_NOTAUTHORIZED, IONETWORKHTTPEX_NOTAUTHORIZED_STR, __LINE__, __FILE__); 
     577                                } 
     578 
     579                                makeDigestAuth(HTTP_RESPONSEHEADER_WWWAUTHENTICATE, HTTP_REQUESTHEADER_AUTHORIZATION, "GET", urlComponents.login, urlComponents.password); 
     580 
     581                                if (proxyAuthInfo.authType == PROXYAUTHTYPE_BASIC) 
     582                                        makeBasicAuth(HTTP_REQUESTHEADER_PROXYAUTHORIZATION, proxyAuthInfo.user, proxyAuthInfo.password); 
     583                                else 
     584                                        makeDigestAuth(HTTP_RESPONSEHEADER_PROXYAUTHENTICATE, HTTP_REQUESTHEADER_PROXYAUTHORIZATION, "GET", proxyAuthInfo.user, proxyAuthInfo.password); 
     585 
     586                                GET(); 
     587 
     588                                break; 
     589                } 
     590        } 
     591        catch (...) 
     592        { 
     593                delete ex; 
     594 
     595                clear(); 
     596 
     597                throw; 
     598        } 
     599 
     600        delete ex; 
     601 
     602        clear(); 
     603} 
     604 
     605//------------------------------------------------------------------- 
     606 
     607__httpResponse 
     608http::GET(const dodoString &a_url) 
     609{ 
     610        setUrl(a_url); 
     611 
     612        GET(); 
     613 
     614        return response; 
     615} 
     616 
     617//------------------------------------------------------------------- 
     618 
     619__httpResponse 
     620http::POST(const dodoString &a_url, 
     621                   const dodoStringMap &arguments, 
     622                   const dodoStringMap &files) 
     623{ 
     624        setUrl(a_url); 
     625 
     626        POST(arguments, files); 
     627 
     628        return response; 
     629} 
     630 
     631//------------------------------------------------------------------- 
     632 
     633void 
     634http::POST(const dodoStringMap &arguments, 
     635                   const dodoStringMap &files) 
     636{ 
     637        dodoString boundary = "---------------------------" + tools::string::ulToString(tools::misc::ulRandom()) + tools::string::ulToString(tools::misc::ulRandom()); 
     638        dodoString type = "multipart/form-data; boundary=" + boundary; 
     639        boundary.insert(0, "--"); 
     640 
     641        dodoString data; 
     642 
     643        dodoStringMap::const_iterator i = files.begin(), j = files.end(); 
     644 
     645        for (; i != j; ++i) 
     646        { 
     647                data.append(boundary); 
     648                data.append("\r\nContent-Disposition: form-data; name=\""); 
     649                data.append(i->first); 
     650                data.append("\"; filename=\""); 
     651                data.append(tools::filesystem::basename(i->second)); 
     652                data.append("\"\r\n"); 
     653 
     654                data.append("Content-Type: application/octet-stream\r\n\r\n"); 
     655 
     656                data.append(tools::filesystem::getFileContents(i->second)); 
     657                data.append("\r\n"); 
     658        } 
     659 
     660        i = arguments.begin(); 
     661        j = arguments.end(); 
     662        for (; i != j; ++i) 
     663        { 
     664                data.append(boundary); 
     665                data.append("\r\nContent-Disposition: form-data; name=\""); 
     666                data.append(i->first); 
     667                data.append("\"\r\n\r\n"); 
     668 
     669                data.append(i->second); 
     670                data.append("\r\n"); 
     671        } 
     672        data.append(boundary); 
     673        data.append("--"); 
     674 
     675        POST(data, type); 
     676} 
     677 
     678//------------------------------------------------------------------- 
     679 
     680__httpResponse 
     681http::POST(const dodoString &a_url, 
     682                   const dodoStringMap &arguments) 
     683{ 
     684        setUrl(a_url); 
     685 
     686        POST(arguments); 
     687 
     688        return response; 
     689} 
     690 
     691//------------------------------------------------------------------- 
     692 
     693void 
     694http::POST(const dodoStringMap &arguments) 
     695{ 
     696        dodoString data; 
     697 
     698        dodoStringMap::const_iterator i(arguments.begin()), j(arguments.end()); 
     699        --j; 
     700 
     701        for (; i != j; ++i) 
     702        { 
     703                data.append(tools::misc::encodeUrl(i->first)); 
     704                data.append("="); 
     705                data.append(tools::misc::encodeUrl(i->second)); 
     706                data.append("&"); 
     707        } 
     708        data.append(tools::misc::encodeUrl(i->first)); 
     709        data.append("="); 
     710        data.append(tools::misc::encodeUrl(i->second)); 
     711 
     712        POST(data, "application/x-www-form-urlencoded"); 
     713} 
     714 
     715//------------------------------------------------------------------- 
     716 
     717__httpResponse 
     718http::POST(const dodoString &a_url, 
     719                   const dodoString &data, 
     720                   const dodoString &type) 
     721{ 
     722        setUrl(a_url); 
     723 
     724        POST(data, type); 
     725 
     726        return response; 
     727} 
     728 
     729//------------------------------------------------------------------- 
     730 
     731void 
     732http::POST(const dodoString &a_data, 
     733                   const dodoString &type) 
     734{ 
     735        response = __httpResponse(); 
     736 
     737        exchange *ex; 
     738        client *net; 
     739 
     740        dodoString data; 
     741 
     742        if (scheme == SCHEME_HTTP) 
     743        { 
     744                net = new client(OPTIONS_PROTO_FAMILY_IPV4, OPTIONS_TRANSFER_TYPE_STREAM); 
     745                ex = new exchange; 
     746        } 
     747 
     748#ifdef OPENSSL_EXT 
     749 
     750        else 
     751        { 
     752                net = new ssl::client(OPTIONS_PROTO_FAMILY_IPV4, OPTIONS_TRANSFER_TYPE_STREAM); 
     753                ex = new ssl::exchange; 
     754        } 
     755 
     756#endif 
     757 
     758        if (proxyAuthInfo.enabled) 
     759        { 
     760                if (scheme == SCHEME_HTTP) 
     761                        net->connect(proxyAuthInfo.host, proxyAuthInfo.port, *ex); 
     762 
     763#ifdef OPENSSL_EXT 
     764 
     765                        else 
     766                        { 
     767                                net->connect(proxyAuthInfo.host, proxyAuthInfo.port, *(exchange *)ex); 
     768                                data.append("CONNECT "); 
     769                                data.append(urlComponents.host); 
     770                                data.append(":"); 
     771                                data.append(urlComponents.port); 
     772                                data.append(" HTTP/1.0\r\n"); 
     773                                if (requestHeaders.find(HTTP_REQUESTHEADER_PROXYAUTHORIZATION) != requestHeaders.end()) 
     774                                { 
     775                                        data.append(requestHeaderStatements[HTTP_REQUESTHEADER_PROXYAUTHORIZATION]); 
     776                                        data.append(": "); 
     777                                        data.append(requestHeaders[HTTP_REQUESTHEADER_PROXYAUTHORIZATION]); 
     778                                        data.append("\r\n"); 
     779                                } 
     780                                data.append("\r\n"); 
     781 
     782                                ex->outSize = data.size(); 
     783                                ex->exchange::_write(data.c_str()); 
     784 
     785                                char proxyData[512]; 
     786                                ex->setInBufferSize(512); 
     787                                ex->inSize = 512; 
     788 
     789                                try 
     790                                { 
     791                                        switch (getProxyConnectResponse(proxyData, ex)) 
     792                                        { 
     793                                                case GETCONTENTSTATUS_NORMAL: 
     794 
     795                                                        break; 
     796 
     797                                                case GETCONTENTSTATUS_PROXYBASICAUTH: 
     798 
     799                                                        if (authTries > 2) 
     800                                                        { 
     801                                                                authTries = 0; 
     802 
     803                                                                throw baseEx(ERRMODULE_IONETWORKHTTP, HTTPEX_POST, ERR_LIBDODO, HTTPEX_NOTAUTHORIZED, IONETWORKHTTPEX_NOTAUTHORIZED_STR, __LINE__, __FILE__); 
     804                                                        } 
     805 
     806                                                        makeBasicAuth(HTTP_REQUESTHEADER_PROXYAUTHORIZATION, proxyAuthInfo.user, proxyAuthInfo.password); 
     807 
     808                                                        delete ex; 
     809                                                        delete net; 
     810                                                        ex = NULL; 
     811                                                        net = NULL; 
     812 
     813                                                        POST(data, type); 
     814 
     815                                                        clear(); 
     816 
     817                                                        return; 
     818 
     819                                                case GETCONTENTSTATUS_PROXYDIGESTAUTH: 
     820 
     821                                                        if (authTries > 2) 
     822                                                        { 
     823                                                                authTries = 0; 
     824 
     825                                                                throw baseEx(ERRMODULE_IONETWORKHTTP, HTTPEX_POST, ERR_LIBDODO, HTTPEX_NOTAUTHORIZED, IONETWORKHTTPEX_NOTAUTHORIZED_STR, __LINE__, __FILE__); 
     826                                                        } 
     827 
     828                                                        makeDigestAuth(HTTP_RESPONSEHEADER_PROXYAUTHENTICATE, HTTP_REQUESTHEADER_PROXYAUTHORIZATION, "POST", proxyAuthInfo.user, proxyAuthInfo.password); 
     829 
     830                                                        delete ex; 
     831                                                        delete net; 
     832                                                        ex = NULL; 
     833                                                        net = NULL; 
     834 
     835                                                        POST(data, type); 
     836 
     837                                                        clear(); 
     838 
     839                                                        return; 
     840                                        } 
     841                                } 
     842                                catch (...) 
     843                                { 
     844                                        delete ex; 
     845                                        delete net; 
     846 
     847                                        clear(); 
     848 
     849                                        throw; 
     850                                } 
     851 
     852                                if (certsSet) 
     853                                        ((ssl::client *)net)->setSertificates(certs); 
     854                                else 
     855                                        ((ssl::client *)net)->initSsl(); 
     856 
     857                                ((ssl::client *)net)->socket = ((ssl::exchange *)ex)->socket; 
     858                                ((ssl::client *)net)->connectSsl(); 
     859 
     860                                ((ssl::exchange *)ex)->sslHandle = ((ssl::client *)net)->sslHandle; 
     861 
     862                                ((ssl::client *)net)->socket = -1; 
     863                                ((ssl::client *)net)->sslHandle = NULL; 
     864                        } 
     865 
     866#endif 
     867        } 
     868        else 
     869        { 
     870                tools::__hostInfo host = tools::network::getHostInfo(urlComponents.host); 
     871 
     872                dodoStringArray::iterator o = host.addresses.begin(), p = host.addresses.end(); 
     873                for (; o != p; ++o) 
     874                        try 
     875                        { 
     876                                if (scheme == SCHEME_HTTP) 
     877                                { 
     878                                        net->connect(*o, tools::string::stringToI(urlComponents.port), *ex); 
     879                                        ex->setInBufferSize(512); 
     880                                        ex->inSize = 512; 
     881                                } 
     882 
     883#ifdef OPENSSL_EXT 
     884 
     885                                else 
     886                                { 
     887                                        if (certsSet) 
     888                                                ((ssl::client *)net)->setSertificates(certs); 
     889 
     890                                        ((ssl::client *)net)->connect(*o, tools::string::stringToI(urlComponents.port), *(ssl::exchange *)ex); 
     891                                        ex->setInBufferSize(512); 
     892                                        ex->inSize = 512; 
     893                                } 
     894 
     895#endif 
     896 
     897                                break; 
     898                        } 
     899                        catch (baseEx &exp) 
     900                        { 
     901#ifdef OPENSSL_EXT 
     902 
     903                                if (exp.funcID == CLIENTEX_CONNECT || exp.funcID == ssl::CLIENTEX_CONNECT) 
     904 
     905#else 
     906 
     907                                if (exp.funcID == CLIENTEX_CONNECT) 
     908 
     909#endif 
     910                                { 
     911                                        if ((o + 1) == p) 
     912                                        { 
     913                                                delete net; 
     914                                                delete ex; 
     915 
    916916                                                throw baseEx(ERRMODULE_IONETWORKHTTP, HTTPEX_POST, ERR_LIBDODO, HTTPEX_CANNOTCONNECT, IONETWORKHTTPEX_CANNOTCONNECT_STR, __LINE__, __FILE__); 
    917917                                        } 
     
    922922                                delete net; 
    923923                                delete ex; 
    924                          
     924 
    925925                                throw; 
    926926                        } 
     
    936936        else 
    937937                data.append(" HTTP/1.0\r\n"); 
    938          
     938 
    939939        if (cacheAuthentification) 
    940940        { 
     
    10961096        { 
    10971097                delete ex; 
    1098          
     1098 
    10991099                clear(); 
    11001100 
     
    11031103 
    11041104        delete ex; 
    1105          
     1105 
    11061106        clear(); 
    11071107} 
     
    12701270                                        { 
    12711271                                                proxyAuthInfo.authType = PROXYAUTHTYPE_BASIC; 
    1272                                                          
     1272 
    12731273                                                return GETCONTENTSTATUS_PROXYBASICAUTH; 
    12741274                                        } 
     
    12781278                                                { 
    12791279                                                        proxyAuthInfo.authType = PROXYAUTHTYPE_DIGEST; 
    1280                                                          
     1280 
    12811281                                                        return GETCONTENTSTATUS_PROXYDIGESTAUTH; 
    12821282                                                } 
     
    15641564                        httpAuth[urlBasePath] = header->second; 
    15651565        } 
    1566          
     1566 
    15671567        requestHeaders.erase(HTTP_REQUESTHEADER_AUTHORIZATION); 
     1568} 
     1569 
     1570//------------------------------------------------------------------- 
     1571 
     1572void 
     1573http::setAuthInfo(const dodoString &user, 
     1574                  const dodoString &password) 
     1575{ 
     1576        urlComponents.login = user; 
     1577        urlComponents.password = password; 
    15681578} 
    15691579 
Note: See TracChangeset for help on using the changeset viewer.