diff options
author | Anton Samokhvalov <pg83@yandex.ru> | 2022-02-10 16:45:17 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:17 +0300 |
commit | d3a398281c6fd1d3672036cb2d63f842d2cb28c5 (patch) | |
tree | dd4bd3ca0f36b817e96812825ffaf10d645803f2 /library/cpp/http/fetch | |
parent | 72cb13b4aff9bc9cf22e49251bc8fd143f82538f (diff) | |
download | ydb-d3a398281c6fd1d3672036cb2d63f842d2cb28c5.tar.gz |
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/http/fetch')
-rw-r--r-- | library/cpp/http/fetch/exthttpcodes.cpp | 364 | ||||
-rw-r--r-- | library/cpp/http/fetch/exthttpcodes.h | 214 | ||||
-rw-r--r-- | library/cpp/http/fetch/http_digest.cpp | 156 | ||||
-rw-r--r-- | library/cpp/http/fetch/http_digest.h | 56 | ||||
-rw-r--r-- | library/cpp/http/fetch/http_socket.cpp | 162 | ||||
-rw-r--r-- | library/cpp/http/fetch/httpfetcher.h | 56 | ||||
-rw-r--r-- | library/cpp/http/fetch/httpfsm.h | 58 | ||||
-rw-r--r-- | library/cpp/http/fetch/httpfsm_ut.cpp | 118 | ||||
-rw-r--r-- | library/cpp/http/fetch/httpheader.h | 110 | ||||
-rw-r--r-- | library/cpp/http/fetch/httpload.cpp | 312 | ||||
-rw-r--r-- | library/cpp/http/fetch/httpload.h | 264 | ||||
-rw-r--r-- | library/cpp/http/fetch/httpparser.h | 94 | ||||
-rw-r--r-- | library/cpp/http/fetch/httpparser_ut.cpp | 172 | ||||
-rw-r--r-- | library/cpp/http/fetch/httpzreader.h | 42 | ||||
-rw-r--r-- | library/cpp/http/fetch/library-htfetch_ut_hreflang_in.h | 304 | ||||
-rw-r--r-- | library/cpp/http/fetch/ya.make | 12 |
16 files changed, 1247 insertions, 1247 deletions
diff --git a/library/cpp/http/fetch/exthttpcodes.cpp b/library/cpp/http/fetch/exthttpcodes.cpp index baa2a2a0fd..acc05650c8 100644 --- a/library/cpp/http/fetch/exthttpcodes.cpp +++ b/library/cpp/http/fetch/exthttpcodes.cpp @@ -1,160 +1,160 @@ -#include "exthttpcodes.h" - +#include "exthttpcodes.h" + #include <cstring> -const ui16 CrazyServer = ShouldDelete | MarkSuspect; +const ui16 CrazyServer = ShouldDelete | MarkSuspect; -struct http_flag { - ui16 http; - ui16 flag; -}; +struct http_flag { + ui16 http; + ui16 flag; +}; static http_flag HTTP_FLAG[] = { - {HTTP_CONTINUE, MarkSuspect}, // 100 - {HTTP_SWITCHING_PROTOCOLS, CrazyServer}, // 101 - {HTTP_PROCESSING, CrazyServer}, // 102 + {HTTP_CONTINUE, MarkSuspect}, // 100 + {HTTP_SWITCHING_PROTOCOLS, CrazyServer}, // 101 + {HTTP_PROCESSING, CrazyServer}, // 102 - {HTTP_OK, ShouldReindex}, // 200 - {HTTP_CREATED, CrazyServer}, // 201 - {HTTP_ACCEPTED, ShouldDelete}, // 202 - {HTTP_NON_AUTHORITATIVE_INFORMATION, ShouldReindex}, // 203 - {HTTP_NO_CONTENT, ShouldDelete}, // 204 - {HTTP_RESET_CONTENT, ShouldDelete}, // 205 - {HTTP_PARTIAL_CONTENT, ShouldReindex}, // 206 - {HTTP_MULTI_STATUS, CrazyServer}, // 207 - {HTTP_ALREADY_REPORTED, CrazyServer}, // 208 - {HTTP_IM_USED, CrazyServer}, // 226 + {HTTP_OK, ShouldReindex}, // 200 + {HTTP_CREATED, CrazyServer}, // 201 + {HTTP_ACCEPTED, ShouldDelete}, // 202 + {HTTP_NON_AUTHORITATIVE_INFORMATION, ShouldReindex}, // 203 + {HTTP_NO_CONTENT, ShouldDelete}, // 204 + {HTTP_RESET_CONTENT, ShouldDelete}, // 205 + {HTTP_PARTIAL_CONTENT, ShouldReindex}, // 206 + {HTTP_MULTI_STATUS, CrazyServer}, // 207 + {HTTP_ALREADY_REPORTED, CrazyServer}, // 208 + {HTTP_IM_USED, CrazyServer}, // 226 - {HTTP_MULTIPLE_CHOICES, CheckLinks | ShouldDelete}, // 300 - {HTTP_MOVED_PERMANENTLY, CheckLocation | ShouldDelete | MoveRedir}, // 301 - {HTTP_FOUND, CheckLocation | ShouldDelete | MoveRedir}, // 302 - {HTTP_SEE_OTHER, CheckLocation | ShouldDelete | MoveRedir}, // 303 - {HTTP_NOT_MODIFIED, 0}, // 304 - {HTTP_USE_PROXY, ShouldDelete}, // 305 - {HTTP_TEMPORARY_REDIRECT, CheckLocation | ShouldDelete | MoveRedir}, // 307 - {HTTP_PERMANENT_REDIRECT, CheckLocation | ShouldDelete | MoveRedir}, // 308 + {HTTP_MULTIPLE_CHOICES, CheckLinks | ShouldDelete}, // 300 + {HTTP_MOVED_PERMANENTLY, CheckLocation | ShouldDelete | MoveRedir}, // 301 + {HTTP_FOUND, CheckLocation | ShouldDelete | MoveRedir}, // 302 + {HTTP_SEE_OTHER, CheckLocation | ShouldDelete | MoveRedir}, // 303 + {HTTP_NOT_MODIFIED, 0}, // 304 + {HTTP_USE_PROXY, ShouldDelete}, // 305 + {HTTP_TEMPORARY_REDIRECT, CheckLocation | ShouldDelete | MoveRedir}, // 307 + {HTTP_PERMANENT_REDIRECT, CheckLocation | ShouldDelete | MoveRedir}, // 308 - {HTTP_BAD_REQUEST, CrazyServer}, // 400 - {HTTP_UNAUTHORIZED, ShouldDelete}, // 401 - {HTTP_PAYMENT_REQUIRED, ShouldDelete}, // 402 - {HTTP_FORBIDDEN, ShouldDelete}, // 403 - {HTTP_NOT_FOUND, ShouldDelete}, // 404 - {HTTP_METHOD_NOT_ALLOWED, ShouldDelete}, // 405 - {HTTP_NOT_ACCEPTABLE, ShouldDelete}, // 406 - {HTTP_PROXY_AUTHENTICATION_REQUIRED, CrazyServer}, // 407 - {HTTP_REQUEST_TIME_OUT, ShouldDisconnect | ShouldRetry | MarkSuspect}, // 408 - {HTTP_CONFLICT, MarkSuspect}, // 409 - {HTTP_GONE, ShouldDelete}, // 410 - {HTTP_LENGTH_REQUIRED, CrazyServer}, // 411 - {HTTP_PRECONDITION_FAILED, CrazyServer}, // 412 - {HTTP_REQUEST_ENTITY_TOO_LARGE, CrazyServer}, // 413 - {HTTP_REQUEST_URI_TOO_LARGE, ShouldDelete}, // 414 - {HTTP_UNSUPPORTED_MEDIA_TYPE, CrazyServer}, // 415 - {HTTP_REQUESTED_RANGE_NOT_SATISFIABLE, CrazyServer}, // 416 - {HTTP_EXPECTATION_FAILED, ShouldDelete}, // 417 - {HTTP_I_AM_A_TEAPOT, CrazyServer}, // 418 - {HTTP_AUTHENTICATION_TIMEOUT, ShouldDelete}, // 419 + {HTTP_BAD_REQUEST, CrazyServer}, // 400 + {HTTP_UNAUTHORIZED, ShouldDelete}, // 401 + {HTTP_PAYMENT_REQUIRED, ShouldDelete}, // 402 + {HTTP_FORBIDDEN, ShouldDelete}, // 403 + {HTTP_NOT_FOUND, ShouldDelete}, // 404 + {HTTP_METHOD_NOT_ALLOWED, ShouldDelete}, // 405 + {HTTP_NOT_ACCEPTABLE, ShouldDelete}, // 406 + {HTTP_PROXY_AUTHENTICATION_REQUIRED, CrazyServer}, // 407 + {HTTP_REQUEST_TIME_OUT, ShouldDisconnect | ShouldRetry | MarkSuspect}, // 408 + {HTTP_CONFLICT, MarkSuspect}, // 409 + {HTTP_GONE, ShouldDelete}, // 410 + {HTTP_LENGTH_REQUIRED, CrazyServer}, // 411 + {HTTP_PRECONDITION_FAILED, CrazyServer}, // 412 + {HTTP_REQUEST_ENTITY_TOO_LARGE, CrazyServer}, // 413 + {HTTP_REQUEST_URI_TOO_LARGE, ShouldDelete}, // 414 + {HTTP_UNSUPPORTED_MEDIA_TYPE, CrazyServer}, // 415 + {HTTP_REQUESTED_RANGE_NOT_SATISFIABLE, CrazyServer}, // 416 + {HTTP_EXPECTATION_FAILED, ShouldDelete}, // 417 + {HTTP_I_AM_A_TEAPOT, CrazyServer}, // 418 + {HTTP_AUTHENTICATION_TIMEOUT, ShouldDelete}, // 419 - {HTTP_MISDIRECTED_REQUEST, CrazyServer}, // 421 - {HTTP_UNPROCESSABLE_ENTITY, CrazyServer}, // 422 - {HTTP_LOCKED, ShouldDelete}, // 423 - {HTTP_FAILED_DEPENDENCY, CrazyServer}, // 424 - {HTTP_UPGRADE_REQUIRED, ShouldDelete}, // 426 - {HTTP_PRECONDITION_REQUIRED, ShouldDelete}, // 428 - {HTTP_TOO_MANY_REQUESTS, ShouldDisconnect | ShouldRetry | MarkSuspect}, // 429 - {HTTP_UNAVAILABLE_FOR_LEGAL_REASONS, ShouldDelete}, // 451 + {HTTP_MISDIRECTED_REQUEST, CrazyServer}, // 421 + {HTTP_UNPROCESSABLE_ENTITY, CrazyServer}, // 422 + {HTTP_LOCKED, ShouldDelete}, // 423 + {HTTP_FAILED_DEPENDENCY, CrazyServer}, // 424 + {HTTP_UPGRADE_REQUIRED, ShouldDelete}, // 426 + {HTTP_PRECONDITION_REQUIRED, ShouldDelete}, // 428 + {HTTP_TOO_MANY_REQUESTS, ShouldDisconnect | ShouldRetry | MarkSuspect}, // 429 + {HTTP_UNAVAILABLE_FOR_LEGAL_REASONS, ShouldDelete}, // 451 - {HTTP_INTERNAL_SERVER_ERROR, MarkSuspect}, // 500 - {HTTP_NOT_IMPLEMENTED, ShouldDelete | ShouldDisconnect}, // 501 - {HTTP_BAD_GATEWAY, MarkSuspect}, // 502 - {HTTP_SERVICE_UNAVAILABLE, ShouldDisconnect | ShouldRetry | MarkSuspect}, // 503 - {HTTP_GATEWAY_TIME_OUT, ShouldDisconnect | ShouldRetry | MarkSuspect}, // 504 - {HTTP_HTTP_VERSION_NOT_SUPPORTED, CrazyServer | ShouldDisconnect}, // 505 + {HTTP_INTERNAL_SERVER_ERROR, MarkSuspect}, // 500 + {HTTP_NOT_IMPLEMENTED, ShouldDelete | ShouldDisconnect}, // 501 + {HTTP_BAD_GATEWAY, MarkSuspect}, // 502 + {HTTP_SERVICE_UNAVAILABLE, ShouldDisconnect | ShouldRetry | MarkSuspect}, // 503 + {HTTP_GATEWAY_TIME_OUT, ShouldDisconnect | ShouldRetry | MarkSuspect}, // 504 + {HTTP_HTTP_VERSION_NOT_SUPPORTED, CrazyServer | ShouldDisconnect}, // 505 - {HTTP_VARIANT_ALSO_NEGOTIATES, CrazyServer | ShouldDisconnect}, // 506 - {HTTP_INSUFFICIENT_STORAGE, CrazyServer | ShouldDisconnect}, // 507 - {HTTP_LOOP_DETECTED, CrazyServer | ShouldDisconnect}, // 508 - {HTTP_BANDWIDTH_LIMIT_EXCEEDED, ShouldDisconnect | ShouldRetry | MarkSuspect}, // 509 - {HTTP_NOT_EXTENDED, ShouldDelete}, // 510 - {HTTP_NETWORK_AUTHENTICATION_REQUIRED, ShouldDelete}, // 511 + {HTTP_VARIANT_ALSO_NEGOTIATES, CrazyServer | ShouldDisconnect}, // 506 + {HTTP_INSUFFICIENT_STORAGE, CrazyServer | ShouldDisconnect}, // 507 + {HTTP_LOOP_DETECTED, CrazyServer | ShouldDisconnect}, // 508 + {HTTP_BANDWIDTH_LIMIT_EXCEEDED, ShouldDisconnect | ShouldRetry | MarkSuspect}, // 509 + {HTTP_NOT_EXTENDED, ShouldDelete}, // 510 + {HTTP_NETWORK_AUTHENTICATION_REQUIRED, ShouldDelete}, // 511 - // custom - {HTTP_BAD_RESPONSE_HEADER, CrazyServer}, // 1000 - {HTTP_CONNECTION_LOST, ShouldRetry}, // 1001 - {HTTP_BODY_TOO_LARGE, ShouldDelete | CanBeFake}, // 1002 - {HTTP_ROBOTS_TXT_DISALLOW, ShouldDelete}, // 1003 - {HTTP_BAD_URL, ShouldDelete}, // 1004 - {HTTP_BAD_MIME, ShouldDelete}, // 1005 - {HTTP_DNS_FAILURE, ShouldDisconnect | MarkSuspect}, // 1006 - {HTTP_BAD_STATUS_CODE, CrazyServer}, // 1007 - {HTTP_BAD_HEADER_STRING, CrazyServer}, // 1008 - {HTTP_BAD_CHUNK, CrazyServer}, // 1009 - {HTTP_CONNECT_FAILED, ShouldDisconnect | ShouldRetry | MarkSuspect}, // 1010 - {HTTP_FILTER_DISALLOW, ShouldDelete}, // 1011 - {HTTP_LOCAL_EIO, ShouldRetry}, // 1012 - {HTTP_BAD_CONTENT_LENGTH, ShouldDelete}, // 1013 - {HTTP_BAD_ENCODING, ShouldDelete}, // 1014 - {HTTP_LENGTH_UNKNOWN, ShouldDelete}, // 1015 - {HTTP_HEADER_EOF, ShouldRetry | CanBeFake}, // 1016 - {HTTP_MESSAGE_EOF, ShouldRetry | CanBeFake}, // 1017 - {HTTP_CHUNK_EOF, ShouldRetry | CanBeFake}, // 1018 - {HTTP_PAST_EOF, ShouldRetry | ShouldDelete | CanBeFake}, // 1019 - {HTTP_HEADER_TOO_LARGE, ShouldDelete}, // 1020 - {HTTP_URL_TOO_LARGE, ShouldDelete}, // 1021 - {HTTP_INTERRUPTED, 0}, // 1022 - {HTTP_CUSTOM_NOT_MODIFIED, 0}, // 1023 - {HTTP_BAD_CONTENT_ENCODING, ShouldDelete}, // 1024 - {HTTP_PROXY_UNKNOWN, 0}, // 1030 - {HTTP_PROXY_REQUEST_TIME_OUT, 0}, // 1031 - {HTTP_PROXY_INTERNAL_ERROR, 0}, // 1032 - {HTTP_PROXY_CONNECT_FAILED, 0}, // 1033 - {HTTP_PROXY_CONNECTION_LOST, 0}, // 1034 - {HTTP_PROXY_NO_PROXY, 0}, // 1035 - {HTTP_PROXY_ERROR, 0}, // 1036 - {HTTP_SSL_ERROR, 0}, // 1037 - {HTTP_CACHED_COPY_NOT_FOUND, 0}, // 1038 - {HTTP_TIMEDOUT_WHILE_BYTES_RECEIVING, ShouldRetry}, // 1039 - {HTTP_FETCHER_BAD_RESPONSE, 0}, // 1040 - {HTTP_FETCHER_MB_ERROR, 0}, // 1041 - {HTTP_SSL_CERT_ERROR, 0}, // 1042 + // custom + {HTTP_BAD_RESPONSE_HEADER, CrazyServer}, // 1000 + {HTTP_CONNECTION_LOST, ShouldRetry}, // 1001 + {HTTP_BODY_TOO_LARGE, ShouldDelete | CanBeFake}, // 1002 + {HTTP_ROBOTS_TXT_DISALLOW, ShouldDelete}, // 1003 + {HTTP_BAD_URL, ShouldDelete}, // 1004 + {HTTP_BAD_MIME, ShouldDelete}, // 1005 + {HTTP_DNS_FAILURE, ShouldDisconnect | MarkSuspect}, // 1006 + {HTTP_BAD_STATUS_CODE, CrazyServer}, // 1007 + {HTTP_BAD_HEADER_STRING, CrazyServer}, // 1008 + {HTTP_BAD_CHUNK, CrazyServer}, // 1009 + {HTTP_CONNECT_FAILED, ShouldDisconnect | ShouldRetry | MarkSuspect}, // 1010 + {HTTP_FILTER_DISALLOW, ShouldDelete}, // 1011 + {HTTP_LOCAL_EIO, ShouldRetry}, // 1012 + {HTTP_BAD_CONTENT_LENGTH, ShouldDelete}, // 1013 + {HTTP_BAD_ENCODING, ShouldDelete}, // 1014 + {HTTP_LENGTH_UNKNOWN, ShouldDelete}, // 1015 + {HTTP_HEADER_EOF, ShouldRetry | CanBeFake}, // 1016 + {HTTP_MESSAGE_EOF, ShouldRetry | CanBeFake}, // 1017 + {HTTP_CHUNK_EOF, ShouldRetry | CanBeFake}, // 1018 + {HTTP_PAST_EOF, ShouldRetry | ShouldDelete | CanBeFake}, // 1019 + {HTTP_HEADER_TOO_LARGE, ShouldDelete}, // 1020 + {HTTP_URL_TOO_LARGE, ShouldDelete}, // 1021 + {HTTP_INTERRUPTED, 0}, // 1022 + {HTTP_CUSTOM_NOT_MODIFIED, 0}, // 1023 + {HTTP_BAD_CONTENT_ENCODING, ShouldDelete}, // 1024 + {HTTP_PROXY_UNKNOWN, 0}, // 1030 + {HTTP_PROXY_REQUEST_TIME_OUT, 0}, // 1031 + {HTTP_PROXY_INTERNAL_ERROR, 0}, // 1032 + {HTTP_PROXY_CONNECT_FAILED, 0}, // 1033 + {HTTP_PROXY_CONNECTION_LOST, 0}, // 1034 + {HTTP_PROXY_NO_PROXY, 0}, // 1035 + {HTTP_PROXY_ERROR, 0}, // 1036 + {HTTP_SSL_ERROR, 0}, // 1037 + {HTTP_CACHED_COPY_NOT_FOUND, 0}, // 1038 + {HTTP_TIMEDOUT_WHILE_BYTES_RECEIVING, ShouldRetry}, // 1039 + {HTTP_FETCHER_BAD_RESPONSE, 0}, // 1040 + {HTTP_FETCHER_MB_ERROR, 0}, // 1041 + {HTTP_SSL_CERT_ERROR, 0}, // 1042 - // Custom (replace HTTP 200/304) - {EXT_HTTP_MIRRMOVE, 0}, // 2000 - {EXT_HTTP_MANUAL_DELETE, ShouldDelete}, // 2001 - {EXT_HTTP_NOTUSED2, ShouldDelete}, // 2002 - {EXT_HTTP_NOTUSED3, ShouldDelete}, // 2003 - {EXT_HTTP_REFRESH, ShouldDelete | CheckLinks | MoveRedir}, // 2004 - {EXT_HTTP_NOINDEX, ShouldDelete | CheckLinks}, // 2005 - {EXT_HTTP_BADCODES, ShouldDelete}, // 2006 - {EXT_HTTP_SITESTAT, ShouldDelete}, // 2007 - {EXT_HTTP_IOERROR, ShouldDelete}, // 2008 - {EXT_HTTP_BASEERROR, ShouldDelete}, // 2009 - {EXT_HTTP_PARSERROR, ShouldDelete | CanBeFake}, // 2010 - {EXT_HTTP_BAD_CHARSET, ShouldDelete | CheckLinks}, // 2011 - {EXT_HTTP_BAD_LANGUAGE, ShouldDelete | CheckLinks}, // 2012 - {EXT_HTTP_NUMERERROR, ShouldDelete}, // 2013 - {EXT_HTTP_EMPTYDOC, ShouldDelete | CheckLinks}, // 2014 - {EXT_HTTP_HUGEDOC, ShouldDelete}, // 2015 - {EXT_HTTP_LINKGARBAGE, ShouldDelete}, // 2016 - {EXT_HTTP_PARSERFAIL, ShouldDelete}, // 2019 - {EXT_HTTP_GZIPERROR, ShouldDelete}, // 2020 - {EXT_HTTP_MANUAL_DELETE_URL, ShouldDelete}, // 2022 - {EXT_HTTP_CUSTOM_PARTIAL_CONTENT, ShouldReindex}, // 2023 - {EXT_HTTP_EMPTY_RESPONSE, ShouldDelete}, // 2024 - {EXT_HTTP_REL_CANONICAL, ShouldDelete | CheckLinks | MoveRedir}, // 2025 - {0, 0}}; + // Custom (replace HTTP 200/304) + {EXT_HTTP_MIRRMOVE, 0}, // 2000 + {EXT_HTTP_MANUAL_DELETE, ShouldDelete}, // 2001 + {EXT_HTTP_NOTUSED2, ShouldDelete}, // 2002 + {EXT_HTTP_NOTUSED3, ShouldDelete}, // 2003 + {EXT_HTTP_REFRESH, ShouldDelete | CheckLinks | MoveRedir}, // 2004 + {EXT_HTTP_NOINDEX, ShouldDelete | CheckLinks}, // 2005 + {EXT_HTTP_BADCODES, ShouldDelete}, // 2006 + {EXT_HTTP_SITESTAT, ShouldDelete}, // 2007 + {EXT_HTTP_IOERROR, ShouldDelete}, // 2008 + {EXT_HTTP_BASEERROR, ShouldDelete}, // 2009 + {EXT_HTTP_PARSERROR, ShouldDelete | CanBeFake}, // 2010 + {EXT_HTTP_BAD_CHARSET, ShouldDelete | CheckLinks}, // 2011 + {EXT_HTTP_BAD_LANGUAGE, ShouldDelete | CheckLinks}, // 2012 + {EXT_HTTP_NUMERERROR, ShouldDelete}, // 2013 + {EXT_HTTP_EMPTYDOC, ShouldDelete | CheckLinks}, // 2014 + {EXT_HTTP_HUGEDOC, ShouldDelete}, // 2015 + {EXT_HTTP_LINKGARBAGE, ShouldDelete}, // 2016 + {EXT_HTTP_PARSERFAIL, ShouldDelete}, // 2019 + {EXT_HTTP_GZIPERROR, ShouldDelete}, // 2020 + {EXT_HTTP_MANUAL_DELETE_URL, ShouldDelete}, // 2022 + {EXT_HTTP_CUSTOM_PARTIAL_CONTENT, ShouldReindex}, // 2023 + {EXT_HTTP_EMPTY_RESPONSE, ShouldDelete}, // 2024 + {EXT_HTTP_REL_CANONICAL, ShouldDelete | CheckLinks | MoveRedir}, // 2025 + {0, 0}}; -static ui16* prepare_flags(http_flag* arg) { +static ui16* prepare_flags(http_flag* arg) { static ui16 flags[EXT_HTTP_CODE_MAX]; - http_flag* ptr; + http_flag* ptr; size_t i; // устанавливаем значение по умолчанию для кодов не перечисленных в таблице выше - for (i = 0; i < EXT_HTTP_CODE_MAX; ++i) + for (i = 0; i < EXT_HTTP_CODE_MAX; ++i) flags[i] = CrazyServer; // устанавливаем флаги для перечисленных кодов - for (ptr = arg; ptr->http; ++ptr) - flags[ptr->http & (EXT_HTTP_CODE_MAX - 1)] = ptr->flag; + for (ptr = arg; ptr->http; ++ptr) + flags[ptr->http & (EXT_HTTP_CODE_MAX - 1)] = ptr->flag; // для стандартных кодов ошибок берем флаги из первого кода каждой группы и проставляем их // всем кодам не перечисленным в таблице выше @@ -164,103 +164,103 @@ static ui16* prepare_flags(http_flag* arg) { // предыдущий цикл затер некоторые флаги перечисленные в таблице выше // восстанавливаем их - for (ptr = arg; ptr->http; ++ptr) - flags[ptr->http & (EXT_HTTP_CODE_MAX - 1)] = ptr->flag; + for (ptr = arg; ptr->http; ++ptr) + flags[ptr->http & (EXT_HTTP_CODE_MAX - 1)] = ptr->flag; return flags; } -ui16* http2status = prepare_flags(HTTP_FLAG); +ui16* http2status = prepare_flags(HTTP_FLAG); TStringBuf ExtHttpCodeStr(int code) noexcept { if (code < HTTP_CODE_MAX) { return HttpCodeStr(code); } switch (code) { - case HTTP_BAD_RESPONSE_HEADER: + case HTTP_BAD_RESPONSE_HEADER: return TStringBuf("Bad response header"); - case HTTP_CONNECTION_LOST: + case HTTP_CONNECTION_LOST: return TStringBuf("Connection lost"); - case HTTP_BODY_TOO_LARGE: + case HTTP_BODY_TOO_LARGE: return TStringBuf("Body too large"); - case HTTP_ROBOTS_TXT_DISALLOW: + case HTTP_ROBOTS_TXT_DISALLOW: return TStringBuf("robots.txt disallow"); - case HTTP_BAD_URL: + case HTTP_BAD_URL: return TStringBuf("Bad url"); - case HTTP_BAD_MIME: + case HTTP_BAD_MIME: return TStringBuf("Bad mime type"); - case HTTP_DNS_FAILURE: + case HTTP_DNS_FAILURE: return TStringBuf("Dns failure"); - case HTTP_BAD_STATUS_CODE: + case HTTP_BAD_STATUS_CODE: return TStringBuf("Bad status code"); - case HTTP_BAD_HEADER_STRING: + case HTTP_BAD_HEADER_STRING: return TStringBuf("Bad header string"); - case HTTP_BAD_CHUNK: + case HTTP_BAD_CHUNK: return TStringBuf("Bad chunk"); - case HTTP_CONNECT_FAILED: + case HTTP_CONNECT_FAILED: return TStringBuf("Connect failed"); - case HTTP_FILTER_DISALLOW: + case HTTP_FILTER_DISALLOW: return TStringBuf("Filter disallow"); - case HTTP_LOCAL_EIO: + case HTTP_LOCAL_EIO: return TStringBuf("Local eio"); - case HTTP_BAD_CONTENT_LENGTH: + case HTTP_BAD_CONTENT_LENGTH: return TStringBuf("Bad content length"); - case HTTP_BAD_ENCODING: + case HTTP_BAD_ENCODING: return TStringBuf("Bad encoding"); - case HTTP_LENGTH_UNKNOWN: + case HTTP_LENGTH_UNKNOWN: return TStringBuf("Length unknown"); - case HTTP_HEADER_EOF: + case HTTP_HEADER_EOF: return TStringBuf("Header EOF"); - case HTTP_MESSAGE_EOF: + case HTTP_MESSAGE_EOF: return TStringBuf("Message EOF"); - case HTTP_CHUNK_EOF: + case HTTP_CHUNK_EOF: return TStringBuf("Chunk EOF"); - case HTTP_PAST_EOF: + case HTTP_PAST_EOF: return TStringBuf("Past EOF"); - case HTTP_HEADER_TOO_LARGE: + case HTTP_HEADER_TOO_LARGE: return TStringBuf("Header is too large"); - case HTTP_URL_TOO_LARGE: + case HTTP_URL_TOO_LARGE: return TStringBuf("Url is too large"); - case HTTP_INTERRUPTED: + case HTTP_INTERRUPTED: return TStringBuf("Interrupted"); - case HTTP_CUSTOM_NOT_MODIFIED: + case HTTP_CUSTOM_NOT_MODIFIED: return TStringBuf("Signature detector thinks that doc is not modified"); - case HTTP_BAD_CONTENT_ENCODING: + case HTTP_BAD_CONTENT_ENCODING: return TStringBuf("Bad content encoding"); - case HTTP_NO_RESOURCES: + case HTTP_NO_RESOURCES: return TStringBuf("No resources"); - case HTTP_FETCHER_SHUTDOWN: + case HTTP_FETCHER_SHUTDOWN: return TStringBuf("Fetcher shutdown"); - case HTTP_CHUNK_TOO_LARGE: + case HTTP_CHUNK_TOO_LARGE: return TStringBuf("Chunk size is too big"); - case HTTP_SERVER_BUSY: + case HTTP_SERVER_BUSY: return TStringBuf("Server is busy"); - case HTTP_SERVICE_UNKNOWN: + case HTTP_SERVICE_UNKNOWN: return TStringBuf("Service is unknown"); - case HTTP_PROXY_UNKNOWN: + case HTTP_PROXY_UNKNOWN: return TStringBuf("Zora: unknown error"); - case HTTP_PROXY_REQUEST_TIME_OUT: + case HTTP_PROXY_REQUEST_TIME_OUT: return TStringBuf("Zora: request time out"); - case HTTP_PROXY_INTERNAL_ERROR: + case HTTP_PROXY_INTERNAL_ERROR: return TStringBuf("Zora: internal server error"); - case HTTP_PROXY_CONNECT_FAILED: + case HTTP_PROXY_CONNECT_FAILED: return TStringBuf("Spider proxy connect failed"); - case HTTP_PROXY_CONNECTION_LOST: + case HTTP_PROXY_CONNECTION_LOST: return TStringBuf("Spider proxy connection lost"); - case HTTP_PROXY_NO_PROXY: + case HTTP_PROXY_NO_PROXY: return TStringBuf("Spider proxy no proxy alive in region"); - case HTTP_PROXY_ERROR: + case HTTP_PROXY_ERROR: return TStringBuf("Spider proxy returned custom error"); - case HTTP_SSL_ERROR: + case HTTP_SSL_ERROR: return TStringBuf("Ssl library returned error"); - case HTTP_CACHED_COPY_NOT_FOUND: + case HTTP_CACHED_COPY_NOT_FOUND: return TStringBuf("Cached copy for the url is not available"); - case HTTP_TIMEDOUT_WHILE_BYTES_RECEIVING: + case HTTP_TIMEDOUT_WHILE_BYTES_RECEIVING: return TStringBuf("Timed out while bytes receiving"); - // TODO: messages for >2000 codes + // TODO: messages for >2000 codes - default: + default: return TStringBuf("Unknown HTTP code"); } } diff --git a/library/cpp/http/fetch/exthttpcodes.h b/library/cpp/http/fetch/exthttpcodes.h index 537e4ac6df..6b525052cd 100644 --- a/library/cpp/http/fetch/exthttpcodes.h +++ b/library/cpp/http/fetch/exthttpcodes.h @@ -5,110 +5,110 @@ enum ExtHttpCodes { // Custom - HTTP_EXTENDED = 1000, - HTTP_BAD_RESPONSE_HEADER = 1000, - HTTP_CONNECTION_LOST = 1001, - HTTP_BODY_TOO_LARGE = 1002, - HTTP_ROBOTS_TXT_DISALLOW = 1003, - HTTP_BAD_URL = 1004, - HTTP_BAD_MIME = 1005, - HTTP_DNS_FAILURE = 1006, - HTTP_BAD_STATUS_CODE = 1007, - HTTP_BAD_HEADER_STRING = 1008, - HTTP_BAD_CHUNK = 1009, - HTTP_CONNECT_FAILED = 1010, - HTTP_FILTER_DISALLOW = 1011, - HTTP_LOCAL_EIO = 1012, - HTTP_BAD_CONTENT_LENGTH = 1013, - HTTP_BAD_ENCODING = 1014, - HTTP_LENGTH_UNKNOWN = 1015, - HTTP_HEADER_EOF = 1016, - HTTP_MESSAGE_EOF = 1017, - HTTP_CHUNK_EOF = 1018, - HTTP_PAST_EOF = 1019, - HTTP_HEADER_TOO_LARGE = 1020, - HTTP_URL_TOO_LARGE = 1021, - HTTP_INTERRUPTED = 1022, - HTTP_CUSTOM_NOT_MODIFIED = 1023, - HTTP_BAD_CONTENT_ENCODING = 1024, - HTTP_NO_RESOURCES = 1025, - HTTP_FETCHER_SHUTDOWN = 1026, - HTTP_CHUNK_TOO_LARGE = 1027, - HTTP_SERVER_BUSY = 1028, - HTTP_SERVICE_UNKNOWN = 1029, - HTTP_PROXY_UNKNOWN = 1030, - HTTP_PROXY_REQUEST_TIME_OUT = 1031, - HTTP_PROXY_INTERNAL_ERROR = 1032, - HTTP_PROXY_CONNECT_FAILED = 1033, - HTTP_PROXY_CONNECTION_LOST = 1034, - HTTP_PROXY_NO_PROXY = 1035, - HTTP_PROXY_ERROR = 1036, - HTTP_SSL_ERROR = 1037, - HTTP_CACHED_COPY_NOT_FOUND = 1038, + HTTP_EXTENDED = 1000, + HTTP_BAD_RESPONSE_HEADER = 1000, + HTTP_CONNECTION_LOST = 1001, + HTTP_BODY_TOO_LARGE = 1002, + HTTP_ROBOTS_TXT_DISALLOW = 1003, + HTTP_BAD_URL = 1004, + HTTP_BAD_MIME = 1005, + HTTP_DNS_FAILURE = 1006, + HTTP_BAD_STATUS_CODE = 1007, + HTTP_BAD_HEADER_STRING = 1008, + HTTP_BAD_CHUNK = 1009, + HTTP_CONNECT_FAILED = 1010, + HTTP_FILTER_DISALLOW = 1011, + HTTP_LOCAL_EIO = 1012, + HTTP_BAD_CONTENT_LENGTH = 1013, + HTTP_BAD_ENCODING = 1014, + HTTP_LENGTH_UNKNOWN = 1015, + HTTP_HEADER_EOF = 1016, + HTTP_MESSAGE_EOF = 1017, + HTTP_CHUNK_EOF = 1018, + HTTP_PAST_EOF = 1019, + HTTP_HEADER_TOO_LARGE = 1020, + HTTP_URL_TOO_LARGE = 1021, + HTTP_INTERRUPTED = 1022, + HTTP_CUSTOM_NOT_MODIFIED = 1023, + HTTP_BAD_CONTENT_ENCODING = 1024, + HTTP_NO_RESOURCES = 1025, + HTTP_FETCHER_SHUTDOWN = 1026, + HTTP_CHUNK_TOO_LARGE = 1027, + HTTP_SERVER_BUSY = 1028, + HTTP_SERVICE_UNKNOWN = 1029, + HTTP_PROXY_UNKNOWN = 1030, + HTTP_PROXY_REQUEST_TIME_OUT = 1031, + HTTP_PROXY_INTERNAL_ERROR = 1032, + HTTP_PROXY_CONNECT_FAILED = 1033, + HTTP_PROXY_CONNECTION_LOST = 1034, + HTTP_PROXY_NO_PROXY = 1035, + HTTP_PROXY_ERROR = 1036, + HTTP_SSL_ERROR = 1037, + HTTP_CACHED_COPY_NOT_FOUND = 1038, HTTP_TIMEDOUT_WHILE_BYTES_RECEIVING = 1039, - HTTP_FETCHER_BAD_RESPONSE = 1040, - HTTP_FETCHER_MB_ERROR = 1041, - HTTP_SSL_CERT_ERROR = 1042, - HTTP_PROXY_REQUEST_CANCELED = 1051, + HTTP_FETCHER_BAD_RESPONSE = 1040, + HTTP_FETCHER_MB_ERROR = 1041, + HTTP_SSL_CERT_ERROR = 1042, + HTTP_PROXY_REQUEST_CANCELED = 1051, // Custom (replace HTTP 200/304) - EXT_HTTP_EXT_SUCCESS_BEGIN = 2000, // to check if code variable is in success interval - EXT_HTTP_MIRRMOVE = 2000, - EXT_HTTP_MANUAL_DELETE = 2001, - EXT_HTTP_NOTUSED2 = 2002, - EXT_HTTP_NOTUSED3 = 2003, - EXT_HTTP_REFRESH = 2004, - EXT_HTTP_NOINDEX = 2005, - EXT_HTTP_BADCODES = 2006, - EXT_HTTP_SITESTAT = 2007, - EXT_HTTP_IOERROR = 2008, - EXT_HTTP_BASEERROR = 2009, - EXT_HTTP_PARSERROR = 2010, - EXT_HTTP_BAD_CHARSET = 2011, - EXT_HTTP_BAD_LANGUAGE = 2012, - EXT_HTTP_NUMERERROR = 2013, - EXT_HTTP_EMPTYDOC = 2014, - EXT_HTTP_HUGEDOC = 2015, - EXT_HTTP_LINKGARBAGE = 2016, - EXT_HTTP_EXDUPLICATE = 2017, - EXT_HTTP_FILTERED = 2018, - EXT_HTTP_PARSERFAIL = 2019, // parser crashed (in this case image spider will redownload such document) - EXT_HTTP_GZIPERROR = 2020, - EXT_HTTP_CLEANPARAM = 2021, - EXT_HTTP_MANUAL_DELETE_URL = 2022, - EXT_HTTP_CUSTOM_PARTIAL_CONTENT = 2023, - EXT_HTTP_EMPTY_RESPONSE = 2024, - EXT_HTTP_REL_CANONICAL = 2025, + EXT_HTTP_EXT_SUCCESS_BEGIN = 2000, // to check if code variable is in success interval + EXT_HTTP_MIRRMOVE = 2000, + EXT_HTTP_MANUAL_DELETE = 2001, + EXT_HTTP_NOTUSED2 = 2002, + EXT_HTTP_NOTUSED3 = 2003, + EXT_HTTP_REFRESH = 2004, + EXT_HTTP_NOINDEX = 2005, + EXT_HTTP_BADCODES = 2006, + EXT_HTTP_SITESTAT = 2007, + EXT_HTTP_IOERROR = 2008, + EXT_HTTP_BASEERROR = 2009, + EXT_HTTP_PARSERROR = 2010, + EXT_HTTP_BAD_CHARSET = 2011, + EXT_HTTP_BAD_LANGUAGE = 2012, + EXT_HTTP_NUMERERROR = 2013, + EXT_HTTP_EMPTYDOC = 2014, + EXT_HTTP_HUGEDOC = 2015, + EXT_HTTP_LINKGARBAGE = 2016, + EXT_HTTP_EXDUPLICATE = 2017, + EXT_HTTP_FILTERED = 2018, + EXT_HTTP_PARSERFAIL = 2019, // parser crashed (in this case image spider will redownload such document) + EXT_HTTP_GZIPERROR = 2020, + EXT_HTTP_CLEANPARAM = 2021, + EXT_HTTP_MANUAL_DELETE_URL = 2022, + EXT_HTTP_CUSTOM_PARTIAL_CONTENT = 2023, + EXT_HTTP_EMPTY_RESPONSE = 2024, + EXT_HTTP_REL_CANONICAL = 2025, - EXT_HTTP_EXT_SUCCESS_END = 3000, // to check if code variable is in success interval - EXT_HTTP_HOSTFILTER = 3001, - EXT_HTTP_URLFILTER = 3002, - EXT_HTTP_SUFFIXFILTER = 3003, - EXT_HTTP_DOMAINFILTER = 3004, - EXT_HTTP_EXTDOMAINFILTER = 3005, - EXT_HTTP_PORTFILTER = 3006, - EXT_HTTP_MIRROR = 3007, - EXT_HTTP_DEEPDIR = 3008, - EXT_HTTP_DUPDIRS = 3009, - EXT_HTTP_REGEXP = 3010, - EXT_HTTP_OLDDELETED = 3012, - EXT_HTTP_PENALTY = 3013, - EXT_HTTP_POLICY = 3015, - EXT_HTTP_TOOOLD = 3016, - EXT_HTTP_GARBAGE = 3017, - EXT_HTTP_FOREIGN = 3018, - EXT_HTTP_EXT_REGEXP = 3019, - EXT_HTTP_HOPS = 3020, - EXT_HTTP_SELRANK = 3021, - EXT_HTTP_NOLINKS = 3022, - EXT_HTTP_WRONGMULTILANG = 3023, - EXT_HTTP_SOFTMIRRORS = 3024, - EXT_HTTP_BIGLEVEL = 3025, + EXT_HTTP_EXT_SUCCESS_END = 3000, // to check if code variable is in success interval + EXT_HTTP_HOSTFILTER = 3001, + EXT_HTTP_URLFILTER = 3002, + EXT_HTTP_SUFFIXFILTER = 3003, + EXT_HTTP_DOMAINFILTER = 3004, + EXT_HTTP_EXTDOMAINFILTER = 3005, + EXT_HTTP_PORTFILTER = 3006, + EXT_HTTP_MIRROR = 3007, + EXT_HTTP_DEEPDIR = 3008, + EXT_HTTP_DUPDIRS = 3009, + EXT_HTTP_REGEXP = 3010, + EXT_HTTP_OLDDELETED = 3012, + EXT_HTTP_PENALTY = 3013, + EXT_HTTP_POLICY = 3015, + EXT_HTTP_TOOOLD = 3016, + EXT_HTTP_GARBAGE = 3017, + EXT_HTTP_FOREIGN = 3018, + EXT_HTTP_EXT_REGEXP = 3019, + EXT_HTTP_HOPS = 3020, + EXT_HTTP_SELRANK = 3021, + EXT_HTTP_NOLINKS = 3022, + EXT_HTTP_WRONGMULTILANG = 3023, + EXT_HTTP_SOFTMIRRORS = 3024, + EXT_HTTP_BIGLEVEL = 3025, // fast robot codes - EXT_HTTP_FASTHOPS = 4000, - EXT_HTTP_NODOC = 4001, + EXT_HTTP_FASTHOPS = 4000, + EXT_HTTP_NODOC = 4001, EXT_HTTP_MAX }; @@ -116,26 +116,26 @@ enum ExtHttpCodes { enum HttpFlags { // connection ShouldDisconnect = 1, - ShouldRetry = 2, + ShouldRetry = 2, // UNUSED 4 // indexer - ShouldReindex = 8, - ShouldDelete = 16, - CheckLocation = 32, - CheckLinks = 64, - MarkSuspect = 128, + ShouldReindex = 8, + ShouldDelete = 16, + CheckLocation = 32, + CheckLinks = 64, + MarkSuspect = 128, // UNUSED 256 // UNUSED 512 - MoveRedir = 1024, - CanBeFake = 2048, + MoveRedir = 1024, + CanBeFake = 2048, }; const size_t EXT_HTTP_CODE_MAX = 1 << 12; static inline int Http2Status(int code) { - extern ui16* http2status; - return http2status[code & (EXT_HTTP_CODE_MAX - 1)]; + extern ui16* http2status; + return http2status[code & (EXT_HTTP_CODE_MAX - 1)]; } TStringBuf ExtHttpCodeStr(int code) noexcept; diff --git a/library/cpp/http/fetch/http_digest.cpp b/library/cpp/http/fetch/http_digest.cpp index 79c5a25319..1eaa02b7f2 100644 --- a/library/cpp/http/fetch/http_digest.cpp +++ b/library/cpp/http/fetch/http_digest.cpp @@ -1,5 +1,5 @@ -#include "http_digest.h" - +#include "http_digest.h" + #include <library/cpp/digest/md5/md5.h> #include <util/stream/output.h> #include <util/stream/str.h> @@ -9,76 +9,76 @@ static const char* WWW_PREFIX = "Authorization: Digest "; /************************************************************/ -httpDigestHandler::httpDigestHandler() - : User_(nullptr) - , Password_(nullptr) - , Nonce_(nullptr) - , NonceCount_(0) - , HeaderInstruction_(nullptr) +httpDigestHandler::httpDigestHandler() + : User_(nullptr) + , Password_(nullptr) + , Nonce_(nullptr) + , NonceCount_(0) + , HeaderInstruction_(nullptr) { } /************************************************************/ -httpDigestHandler::~httpDigestHandler() { +httpDigestHandler::~httpDigestHandler() { clear(); } /************************************************************/ -void httpDigestHandler::clear() { - free(Nonce_); - free(HeaderInstruction_); +void httpDigestHandler::clear() { + free(Nonce_); + free(HeaderInstruction_); User_ = Password_ = nullptr; Nonce_ = HeaderInstruction_ = nullptr; - NonceCount_ = 0; + NonceCount_ = 0; } /************************************************************/ -void httpDigestHandler::setAuthorization(const char* user, const char* password) { +void httpDigestHandler::setAuthorization(const char* user, const char* password) { clear(); - if (user && password) { - User_ = user; - Password_ = password; + if (user && password) { + User_ = user; + Password_ = password; } } /************************************************************/ -const char* httpDigestHandler::getHeaderInstruction() const { - return HeaderInstruction_; +const char* httpDigestHandler::getHeaderInstruction() const { + return HeaderInstruction_; } /************************************************************/ -void httpDigestHandler::generateCNonce(char* outCNonce) { +void httpDigestHandler::generateCNonce(char* outCNonce) { if (!*outCNonce) sprintf(outCNonce, "%ld", (long)time(nullptr)); } /************************************************************/ -inline void addMD5(MD5& ctx, const char* value) { +inline void addMD5(MD5& ctx, const char* value) { ctx.Update((const unsigned char*)(value), strlen(value)); } -inline void addMD5(MD5& ctx, const char* value, int len) { +inline void addMD5(MD5& ctx, const char* value, int len) { ctx.Update((const unsigned char*)(value), len); } -inline void addMD5Sep(MD5& ctx) { +inline void addMD5Sep(MD5& ctx) { addMD5(ctx, ":", 1); } /************************************************************/ /* calculate H(A1) as per spec */ -void httpDigestHandler::digestCalcHA1(const THttpAuthHeader& hd, - char* outSessionKey, - char* outCNonce) { +void httpDigestHandler::digestCalcHA1(const THttpAuthHeader& hd, + char* outSessionKey, + char* outCNonce) { MD5 ctx; ctx.Init(); - addMD5(ctx, User_); - addMD5Sep(ctx); - addMD5(ctx, hd.realm); - addMD5Sep(ctx); - addMD5(ctx, Password_); + addMD5(ctx, User_); + addMD5Sep(ctx); + addMD5(ctx, hd.realm); + addMD5Sep(ctx); + addMD5(ctx, Password_); - if (hd.algorithm == 1) { //MD5-sess + if (hd.algorithm == 1) { //MD5-sess unsigned char digest[16]; ctx.Final(digest); @@ -86,91 +86,91 @@ void httpDigestHandler::digestCalcHA1(const THttpAuthHeader& hd, ctx.Init(); ctx.Update(digest, 16); - addMD5Sep(ctx); - addMD5(ctx, hd.nonce); - addMD5Sep(ctx); - addMD5(ctx, outCNonce); + addMD5Sep(ctx); + addMD5(ctx, hd.nonce); + addMD5Sep(ctx); + addMD5(ctx, outCNonce); ctx.End(outSessionKey); } - ctx.End(outSessionKey); + ctx.End(outSessionKey); }; /************************************************************/ /* calculate request-digest/response-digest as per HTTP Digest spec */ -void httpDigestHandler::digestCalcResponse(const THttpAuthHeader& hd, - const char* path, - const char* method, - const char* nonceCount, - char* outResponse, - char* outCNonce) { +void httpDigestHandler::digestCalcResponse(const THttpAuthHeader& hd, + const char* path, + const char* method, + const char* nonceCount, + char* outResponse, + char* outCNonce) { char HA1[33]; digestCalcHA1(hd, HA1, outCNonce); char HA2[33]; MD5 ctx; ctx.Init(); - addMD5(ctx, method); - addMD5Sep(ctx); - addMD5(ctx, path); + addMD5(ctx, method); + addMD5Sep(ctx); + addMD5(ctx, path); //ignore auth-int ctx.End(HA2); ctx.Init(); - addMD5(ctx, HA1, 32); - addMD5Sep(ctx); - addMD5(ctx, Nonce_); - addMD5Sep(ctx); + addMD5(ctx, HA1, 32); + addMD5Sep(ctx); + addMD5(ctx, Nonce_); + addMD5Sep(ctx); - if (hd.qop_auth) { + if (hd.qop_auth) { if (!*outCNonce) generateCNonce(outCNonce); - addMD5(ctx, nonceCount, 8); - addMD5Sep(ctx); - addMD5(ctx, outCNonce); - addMD5Sep(ctx); - addMD5(ctx, "auth", 4); - addMD5Sep(ctx); + addMD5(ctx, nonceCount, 8); + addMD5Sep(ctx); + addMD5(ctx, outCNonce); + addMD5Sep(ctx); + addMD5(ctx, "auth", 4); + addMD5Sep(ctx); } - addMD5(ctx, HA2, 32); + addMD5(ctx, HA2, 32); ctx.End(outResponse); } /************************************************************/ -bool httpDigestHandler::processHeader(const THttpAuthHeader* header, - const char* path, - const char* method, - const char* cnonce) { - if (!User_ || !header || !header->use_auth || !header->realm || !header->nonce) +bool httpDigestHandler::processHeader(const THttpAuthHeader* header, + const char* path, + const char* method, + const char* cnonce) { + if (!User_ || !header || !header->use_auth || !header->realm || !header->nonce) return false; - if (Nonce_) { - if (strcmp(Nonce_, header->nonce)) { - free(Nonce_); + if (Nonce_) { + if (strcmp(Nonce_, header->nonce)) { + free(Nonce_); Nonce_ = nullptr; - NonceCount_ = 0; + NonceCount_ = 0; } } - if (!Nonce_) { - Nonce_ = strdup(header->nonce); - NonceCount_ = 0; + if (!Nonce_) { + Nonce_ = strdup(header->nonce); + NonceCount_ = 0; } - free(HeaderInstruction_); + free(HeaderInstruction_); HeaderInstruction_ = nullptr; - NonceCount_++; + NonceCount_++; char nonceCount[20]; - sprintf(nonceCount, "%08d", NonceCount_); + sprintf(nonceCount, "%08d", NonceCount_); char CNonce[50]; if (cnonce) strcpy(CNonce, cnonce); else - CNonce[0] = 0; + CNonce[0] = 0; char response[33]; - digestCalcResponse(*header, path, method, nonceCount, response, CNonce); + digestCalcResponse(*header, path, method, nonceCount, response, CNonce); //digest-response = 1#( username | realm | nonce | digest-uri // | response | [ algorithm ] | [cnonce] | @@ -178,11 +178,11 @@ bool httpDigestHandler::processHeader(const THttpAuthHeader* header, // [nonce-count] | [auth-param] ) TStringStream out; - out << WWW_PREFIX << "username=\"" << User_ << "\""; + out << WWW_PREFIX << "username=\"" << User_ << "\""; out << ", realm=\"" << header->realm << "\""; out << ", nonce=\"" << header->nonce << "\""; out << ", uri=\"" << path << "\""; - if (header->algorithm == 1) + if (header->algorithm == 1) out << ", algorithm=MD5-sess"; else out << ", algorithm=MD5"; @@ -197,7 +197,7 @@ bool httpDigestHandler::processHeader(const THttpAuthHeader* header, out << "\r\n"; TString s_out = out.Str(); - HeaderInstruction_ = strdup(s_out.c_str()); + HeaderInstruction_ = strdup(s_out.c_str()); return true; } diff --git a/library/cpp/http/fetch/http_digest.h b/library/cpp/http/fetch/http_digest.h index 958737a6ac..3b1872d70b 100644 --- a/library/cpp/http/fetch/http_digest.h +++ b/library/cpp/http/fetch/http_digest.h @@ -1,46 +1,46 @@ #pragma once -#include "httpheader.h" - +#include "httpheader.h" + #include <util/system/compat.h> #include <library/cpp/http/misc/httpcodes.h> -class httpDigestHandler { -protected: - const char* User_; - const char* Password_; - char* Nonce_; - int NonceCount_; - char* HeaderInstruction_; +class httpDigestHandler { +protected: + const char* User_; + const char* Password_; + char* Nonce_; + int NonceCount_; + char* HeaderInstruction_; void clear(); - void generateCNonce(char* outCNonce); + void generateCNonce(char* outCNonce); - void digestCalcHA1(const THttpAuthHeader& hd, - char* outSessionKey, - char* outCNonce); + void digestCalcHA1(const THttpAuthHeader& hd, + char* outSessionKey, + char* outCNonce); - void digestCalcResponse(const THttpAuthHeader& hd, - const char* method, - const char* path, - const char* nonceCount, - char* outResponse, - char* outCNonce); + void digestCalcResponse(const THttpAuthHeader& hd, + const char* method, + const char* path, + const char* nonceCount, + char* outResponse, + char* outCNonce); -public: +public: httpDigestHandler(); ~httpDigestHandler(); - void setAuthorization(const char* user, - const char* password); - bool processHeader(const THttpAuthHeader* header, - const char* path, - const char* method, - const char* cnonce = nullptr); + void setAuthorization(const char* user, + const char* password); + bool processHeader(const THttpAuthHeader* header, + const char* path, + const char* method, + const char* cnonce = nullptr); - bool empty() const { - return (!User_); + bool empty() const { + return (!User_); } const char* getHeaderInstruction() const; diff --git a/library/cpp/http/fetch/http_socket.cpp b/library/cpp/http/fetch/http_socket.cpp index 7a5b29668c..1524ef04a8 100644 --- a/library/cpp/http/fetch/http_socket.cpp +++ b/library/cpp/http/fetch/http_socket.cpp @@ -7,7 +7,7 @@ #include <gcrypt.h> #include <gnutls/gnutls.h> -#include <util/network/init.h> +#include <util/network/init.h> #include <util/network/socket.h> #include <util/system/mutex.h> @@ -15,75 +15,75 @@ // HTTPS handler is used as implementation of // socketAbstractHandler for work through HTTPS protocol -class socketSecureHandler: public socketRegularHandler { -protected: - bool IsValid_; - gnutls_session Session_; - gnutls_certificate_credentials Credits_; - -public: - socketSecureHandler(); - virtual ~socketSecureHandler(); - - virtual bool Good(); - virtual int Connect(const TAddrList& addrs, TDuration Timeout); - virtual void Disconnect(); - virtual void shutdown(); - virtual bool send(const char* message, ssize_t messlen); - virtual bool peek(); - virtual ssize_t read(void* buffer, ssize_t buflen); +class socketSecureHandler: public socketRegularHandler { +protected: + bool IsValid_; + gnutls_session Session_; + gnutls_certificate_credentials Credits_; + +public: + socketSecureHandler(); + virtual ~socketSecureHandler(); + + virtual bool Good(); + virtual int Connect(const TAddrList& addrs, TDuration Timeout); + virtual void Disconnect(); + virtual void shutdown(); + virtual bool send(const char* message, ssize_t messlen); + virtual bool peek(); + virtual ssize_t read(void* buffer, ssize_t buflen); }; /********************************************************/ /********************************************************/ -static int gcry_pthread_mutex_init(void** priv) { +static int gcry_pthread_mutex_init(void** priv) { int err = 0; try { TMutex* lock = new TMutex; *priv = lock; - } catch (...) { + } catch (...) { err = -1; } return err; } -static int gcry_pthread_mutex_destroy(void** lock) { +static int gcry_pthread_mutex_destroy(void** lock) { delete static_cast<TMutex*>(*lock); - + return 0; } -static int gcry_pthread_mutex_lock(void** lock) { +static int gcry_pthread_mutex_lock(void** lock) { static_cast<TMutex*>(*lock)->Acquire(); return 0; } -static int gcry_pthread_mutex_unlock(void** lock) { +static int gcry_pthread_mutex_unlock(void** lock) { static_cast<TMutex*>(*lock)->Release(); return 0; } static struct gcry_thread_cbs gcry_threads_pthread = - { - GCRY_THREAD_OPTION_PTHREAD, NULL, - gcry_pthread_mutex_init, gcry_pthread_mutex_destroy, - gcry_pthread_mutex_lock, gcry_pthread_mutex_unlock, - NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL}; + { + GCRY_THREAD_OPTION_PTHREAD, NULL, + gcry_pthread_mutex_init, gcry_pthread_mutex_destroy, + gcry_pthread_mutex_lock, gcry_pthread_mutex_unlock, + NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL}; /********************************************************/ -struct https_initor { - https_initor() { - gcry_control(GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread); +struct https_initor { + https_initor() { + gcry_control(GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread); gnutls_global_init(); - InitNetworkSubSystem(); + InitNetworkSubSystem(); } - ~https_initor() { + ~https_initor() { gnutls_global_deinit(); } }; @@ -91,112 +91,112 @@ struct https_initor { static https_initor _initor; /********************************************************/ -socketSecureHandler::socketSecureHandler() - : socketRegularHandler() - , IsValid_(false) - , Session_() - , Credits_() +socketSecureHandler::socketSecureHandler() + : socketRegularHandler() + , IsValid_(false) + , Session_() + , Credits_() { } /********************************************************/ -socketSecureHandler::~socketSecureHandler() { - if (IsValid_) +socketSecureHandler::~socketSecureHandler() { + if (IsValid_) Disconnect(); } /********************************************************/ -bool socketSecureHandler::Good() { - return Socket_.Good() && IsValid_; +bool socketSecureHandler::Good() { + return Socket_.Good() && IsValid_; } /********************************************************/ -int socketSecureHandler::Connect(const TAddrList& addrs, TDuration Timeout) { - IsValid_ = false; +int socketSecureHandler::Connect(const TAddrList& addrs, TDuration Timeout) { + IsValid_ = false; int ret = socketRegularHandler::Connect(addrs, Timeout); if (ret) return ret; - gnutls_certificate_allocate_credentials(&Credits_); - gnutls_init(&Session_, GNUTLS_CLIENT); - gnutls_set_default_priority(Session_); - gnutls_credentials_set(Session_, GNUTLS_CRD_CERTIFICATE, Credits_); + gnutls_certificate_allocate_credentials(&Credits_); + gnutls_init(&Session_, GNUTLS_CLIENT); + gnutls_set_default_priority(Session_); + gnutls_credentials_set(Session_, GNUTLS_CRD_CERTIFICATE, Credits_); - SOCKET fd = Socket_; - gnutls_transport_set_ptr(Session_, (gnutls_transport_ptr)fd); + SOCKET fd = Socket_; + gnutls_transport_set_ptr(Session_, (gnutls_transport_ptr)fd); - ret = gnutls_handshake(Session_); + ret = gnutls_handshake(Session_); - if (ret < 0) { + if (ret < 0) { fprintf(stderr, "*** Handshake failed\n"); gnutls_perror(ret); - gnutls_deinit(Session_); - if (Credits_) { - gnutls_certificate_free_credentials(Credits_); - Credits_ = 0; + gnutls_deinit(Session_); + if (Credits_) { + gnutls_certificate_free_credentials(Credits_); + Credits_ = 0; } return 1; } - IsValid_ = true; - return !IsValid_; + IsValid_ = true; + return !IsValid_; } /********************************************************/ -void socketSecureHandler::Disconnect() { - if (IsValid_) { - gnutls_bye(Session_, GNUTLS_SHUT_RDWR); - IsValid_ = false; - gnutls_deinit(Session_); +void socketSecureHandler::Disconnect() { + if (IsValid_) { + gnutls_bye(Session_, GNUTLS_SHUT_RDWR); + IsValid_ = false; + gnutls_deinit(Session_); } - if (Credits_) { - gnutls_certificate_free_credentials(Credits_); - Credits_ = 0; + if (Credits_) { + gnutls_certificate_free_credentials(Credits_); + Credits_ = 0; } socketRegularHandler::Disconnect(); } /********************************************************/ -void socketSecureHandler::shutdown() { +void socketSecureHandler::shutdown() { } /********************************************************/ -bool socketSecureHandler::send(const char* message, ssize_t messlen) { - if (!IsValid_) +bool socketSecureHandler::send(const char* message, ssize_t messlen) { + if (!IsValid_) return false; - ssize_t rv = gnutls_record_send(Session_, message, messlen); + ssize_t rv = gnutls_record_send(Session_, message, messlen); return rv >= 0; } /********************************************************/ -bool socketSecureHandler::peek() { +bool socketSecureHandler::peek() { //ssize_t rv = gnutls_record_check_pending(mSession); //return rv>0; return true; } /********************************************************/ -ssize_t socketSecureHandler::read(void* buffer, ssize_t buflen) { - if (!IsValid_) +ssize_t socketSecureHandler::read(void* buffer, ssize_t buflen) { + if (!IsValid_) return false; - return gnutls_record_recv(Session_, (char*)buffer, buflen); + return gnutls_record_recv(Session_, (char*)buffer, buflen); } #endif /************************************************************/ -socketAbstractHandler* socketHandlerFactory::chooseHandler(const THttpURL& url) { - if (url.IsValidGlobal() && url.GetScheme() == THttpURL::SchemeHTTP) +socketAbstractHandler* socketHandlerFactory::chooseHandler(const THttpURL& url) { + if (url.IsValidGlobal() && url.GetScheme() == THttpURL::SchemeHTTP) return new socketRegularHandler; -#ifdef USE_GNUTLS - if (url.IsValidGlobal() && url.GetScheme() == THttpURL::SchemeHTTPS) +#ifdef USE_GNUTLS + if (url.IsValidGlobal() && url.GetScheme() == THttpURL::SchemeHTTPS) return new socketSecureHandler; -#endif +#endif return nullptr; } diff --git a/library/cpp/http/fetch/httpfetcher.h b/library/cpp/http/fetch/httpfetcher.h index 4b02eef5fc..7fc251afd2 100644 --- a/library/cpp/http/fetch/httpfetcher.h +++ b/library/cpp/http/fetch/httpfetcher.h @@ -1,7 +1,7 @@ #pragma once #ifdef _MSC_VER -#include <io.h> +#include <io.h> #endif #include <library/cpp/http/misc/httpdate.h> @@ -10,27 +10,27 @@ #include "httpparser.h" struct TFakeBackup { - int Write(void* /*buf*/, size_t /*size*/) { - return 0; - } + int Write(void* /*buf*/, size_t /*size*/) { + return 0; + } }; template <size_t bufsize = 5000> struct TFakeAlloc { - void Shrink(void* /*buf*/, size_t /*size*/) { - } - void* Grab(size_t /*min*/, size_t* real) { - *real = bufsize; - return buf; - } - char buf[bufsize]; + void Shrink(void* /*buf*/, size_t /*size*/) { + } + void* Grab(size_t /*min*/, size_t* real) { + *real = bufsize; + return buf; + } + char buf[bufsize]; }; -template <typename TAlloc = TFakeAlloc<>, - typename TCheck = TFakeCheck<>, +template <typename TAlloc = TFakeAlloc<>, + typename TCheck = TFakeCheck<>, typename TWriter = TFakeBackup, - typename TAgent = THttpAgent<>> -class THttpFetcher: public THttpParser<TCheck>, public TAlloc, public TWriter, public TAgent { + typename TAgent = THttpAgent<>> +class THttpFetcher: public THttpParser<TCheck>, public TAlloc, public TWriter, public TAgent { public: static const size_t TCP_MIN = 1500; static int TerminateNow; @@ -40,21 +40,21 @@ public: , TAlloc() , TWriter() , TAgent() - { - } + { + } - virtual ~THttpFetcher() { - } + virtual ~THttpFetcher() { + } - int Fetch(THttpHeader* header, const char* path, const char* const* headers, int persistent, bool head_request = false) { + int Fetch(THttpHeader* header, const char* path, const char* const* headers, int persistent, bool head_request = false) { int ret = 0; int fetcherr = 0; THttpParser<TCheck>::Init(header, head_request); - const char* scheme = HttpUrlSchemeKindToString((THttpURL::TSchemeKind)TAgent::GetScheme()); + const char* scheme = HttpUrlSchemeKindToString((THttpURL::TSchemeKind)TAgent::GetScheme()); size_t schemelen = strlen(scheme); if (*path == '/') { - header->base = TStringBuf(scheme, schemelen); + header->base = TStringBuf(scheme, schemelen); header->base += TStringBuf("://", 3); header->base += TStringBuf(TAgent::pHostBeg, TAgent::pHostEnd - TAgent::pHostBeg); header->base += path; @@ -95,9 +95,9 @@ public: } if ((got = TAgent::read(bufptr, buffree)) < 0) { fetcherr = errno; - if (errno == EINTR) + if (errno == EINTR) header->error = HTTP_INTERRUPTED; - else if (errno == ETIMEDOUT) + else if (errno == ETIMEDOUT) header->error = HTTP_TIMEDOUT_WHILE_BYTES_RECEIVING; else header->error = HTTP_CONNECTION_LOST; @@ -113,7 +113,7 @@ public: THttpParser<TCheck>::Parse(parsebuf, got); if (header->error) - break; //if ANY error ocurred we will stop download that file or will have unprognosed stream position until MAX size reached + break; //if ANY error ocurred we will stop download that file or will have unprognosed stream position until MAX size reached if (inheader && THttpParser<TCheck>::GetState() != THttpParser<TCheck>::hp_in_header) { inheader = 0; @@ -141,12 +141,12 @@ public: i64 Adjustment = 0; if (!header->error) { - if (header->transfer_chunked) { + if (header->transfer_chunked) { Adjustment = header->header_size + header->entity_size - bufsize - 1; - } else if (header->content_length >= 0) { + } else if (header->content_length >= 0) { Adjustment = header->header_size + header->content_length - bufsize; } - if (Adjustment > 0) + if (Adjustment > 0) Adjustment = 0; } diff --git a/library/cpp/http/fetch/httpfsm.h b/library/cpp/http/fetch/httpfsm.h index af490adc5a..c4abdcd0d2 100644 --- a/library/cpp/http/fetch/httpfsm.h +++ b/library/cpp/http/fetch/httpfsm.h @@ -1,7 +1,7 @@ #pragma once -#include "httpheader.h" - +#include "httpheader.h" + #include <util/system/maxlen.h> #include <util/datetime/parser.h> @@ -15,7 +15,7 @@ struct THttpHeaderParser { static constexpr int NeedMore = 1; static constexpr int Accepted = 2; - int Execute(const void* inBuf, size_t len) { + int Execute(const void* inBuf, size_t len) { return execute((unsigned char*)inBuf, (int)len); } @@ -23,7 +23,7 @@ struct THttpHeaderParser { return Execute(str.data(), str.size()); } - int Init(THttpHeader* h) { + int Init(THttpHeader* h) { int ret = Init((THttpBaseHeader*)(h)); hd = h; hd->Init(); @@ -32,43 +32,43 @@ struct THttpHeaderParser { return ret; } - int Init(THttpAuthHeader* h) { + int Init(THttpAuthHeader* h) { int ret = Init((THttpHeader*)(h)); auth_hd = h; return ret; } - int Init(THttpRequestHeader* h) { + int Init(THttpRequestHeader* h) { int ret = Init((THttpBaseHeader*)(h)); request_hd = h; request_hd->Init(); return ret; } - THttpHeader* hd; - long I; - int Dc; + THttpHeader* hd; + long I; + int Dc; TDateTimeFieldsDeprecated DateTimeFields; - char buf[FETCHER_URL_MAX]; - size_t buflen; - char* lastchar; + char buf[FETCHER_URL_MAX]; + size_t buflen; + char* lastchar; - const unsigned char* langstart; - size_t langlen; + const unsigned char* langstart; + size_t langlen; - char* hreflangpos; - size_t hreflangspace; + char* hreflangpos; + size_t hreflangspace; bool AcceptingXRobots; - THttpAuthHeader* auth_hd; - THttpRequestHeader* request_hd; + THttpAuthHeader* auth_hd; + THttpRequestHeader* request_hd; private: - THttpBaseHeader* base_hd; + THttpBaseHeader* base_hd; int cs; - + private: - int Init(THttpBaseHeader* header) { + int Init(THttpBaseHeader* header) { base_hd = header; auth_hd = nullptr; request_hd = nullptr; @@ -77,12 +77,12 @@ private: return 0; } - int execute(unsigned char* inBuf, int len); + int execute(unsigned char* inBuf, int len); void init(); }; struct THttpChunkParser { - int Execute(const void* inBuf, int len) { + int Execute(const void* inBuf, int len) { return execute((unsigned char*)inBuf, len); } @@ -91,14 +91,14 @@ struct THttpChunkParser { return 0; } - int chunk_length; - char* lastchar; - long I; - int Dc; - i64 cnt64; + int chunk_length; + char* lastchar; + long I; + int Dc; + i64 cnt64; private: int cs; - int execute(unsigned char* inBuf, int len); + int execute(unsigned char* inBuf, int len); void init(); }; diff --git a/library/cpp/http/fetch/httpfsm_ut.cpp b/library/cpp/http/fetch/httpfsm_ut.cpp index d6393abd48..b018e80101 100644 --- a/library/cpp/http/fetch/httpfsm_ut.cpp +++ b/library/cpp/http/fetch/httpfsm_ut.cpp @@ -1,22 +1,22 @@ -#include "httpfsm.h" +#include "httpfsm.h" #include "library-htfetch_ut_hreflang_in.h" #include "library-htfetch_ut_hreflang_out.h" - + #include <util/generic/ptr.h> #include <library/cpp/charset/doccodes.h> #include <library/cpp/testing/unittest/registar.h> class THttpHeaderParserTestSuite: public TTestBase { UNIT_TEST_SUITE(THttpHeaderParserTestSuite); - UNIT_TEST(TestRequestHeader); - UNIT_TEST(TestSplitRequestHeader); - UNIT_TEST(TestTrailingData); - UNIT_TEST(TestProxyRequestHeader); - UNIT_TEST(TestIncorrectRequestHeader); - UNIT_TEST(TestLastModified); - UNIT_TEST(TestLastModifiedCorrupted); - UNIT_TEST(TestResponseHeaderOnRequest); - UNIT_TEST(TestRequestHeaderOnResponse); + UNIT_TEST(TestRequestHeader); + UNIT_TEST(TestSplitRequestHeader); + UNIT_TEST(TestTrailingData); + UNIT_TEST(TestProxyRequestHeader); + UNIT_TEST(TestIncorrectRequestHeader); + UNIT_TEST(TestLastModified); + UNIT_TEST(TestLastModifiedCorrupted); + UNIT_TEST(TestResponseHeaderOnRequest); + UNIT_TEST(TestRequestHeaderOnResponse); UNIT_TEST(TestXRobotsTagUnknownTags); UNIT_TEST(TestXRobotsTagMyBot); UNIT_TEST(TestXRobotsTagOtherBot); @@ -25,20 +25,20 @@ class THttpHeaderParserTestSuite: public TTestBase { UNIT_TEST(TestXRobotsTagOverridePriority); UNIT_TEST(TestXRobotsTagDoesNotBreakCharset); UNIT_TEST(TestXRobotsTagAllowsMultiline); - UNIT_TEST(TestRelCanonical); - UNIT_TEST(TestHreflang); - UNIT_TEST(TestHreflangOnLongInput); - UNIT_TEST(TestMimeType); + UNIT_TEST(TestRelCanonical); + UNIT_TEST(TestHreflang); + UNIT_TEST(TestHreflangOnLongInput); + UNIT_TEST(TestMimeType); UNIT_TEST(TestRepeatedContentEncoding); UNIT_TEST_SUITE_END(); - + private: THolder<THttpHeaderParser> httpHeaderParser; - + private: void TestStart(); void TestFinish(); - + public: void TestRequestHeader(); void TestSplitRequestHeader(); @@ -76,8 +76,8 @@ void THttpHeaderParserTestSuite::TestRequestHeader() { TestStart(); THttpRequestHeader httpRequestHeader; httpHeaderParser->Init(&httpRequestHeader); - const char* request = "GET /search?q=hi HTTP/1.1\r\n" - "Host: www.google.ru:8080\r\n\r\n"; + const char* request = "GET /search?q=hi HTTP/1.1\r\n" + "Host: www.google.ru:8080\r\n\r\n"; i32 result = httpHeaderParser->Execute(request, strlen(request)); UNIT_ASSERT_EQUAL(result, 2); UNIT_ASSERT_EQUAL(httpRequestHeader.http_method, HTTP_METHOD_GET); @@ -85,11 +85,11 @@ void THttpHeaderParserTestSuite::TestRequestHeader() { UNIT_ASSERT_EQUAL(httpRequestHeader.request_uri, "/search?q=hi"); UNIT_ASSERT_EQUAL(httpRequestHeader.GetUrl(), "http://www.google.ru:8080/search?q=hi"); UNIT_ASSERT_EQUAL(httpHeaderParser->lastchar - request + 1, - (i32)strlen(request)); + (i32)strlen(request)); UNIT_ASSERT_EQUAL(httpRequestHeader.x_yandex_response_timeout, - DEFAULT_RESPONSE_TIMEOUT); + DEFAULT_RESPONSE_TIMEOUT); UNIT_ASSERT_EQUAL(httpRequestHeader.x_yandex_request_priority, - DEFAULT_REQUEST_PRIORITY); + DEFAULT_REQUEST_PRIORITY); UNIT_ASSERT_EQUAL(strcmp(httpRequestHeader.x_yandex_sourcename, ""), 0); UNIT_ASSERT_EQUAL(strcmp(httpRequestHeader.x_yandex_requesttype, ""), 0); UNIT_ASSERT_EQUAL(strcmp(httpRequestHeader.x_yandex_fetchoptions, ""), 0); @@ -99,7 +99,7 @@ void THttpHeaderParserTestSuite::TestRequestHeader() { void THttpHeaderParserTestSuite::TestSplitRequestHeader() { TestStart(); - const char* request = + const char* request = "GET /search?q=hi HTTP/1.1\r\n" "Host: www.google.ru:8080 \r\n" "\r\n"; @@ -108,8 +108,8 @@ void THttpHeaderParserTestSuite::TestSplitRequestHeader() { for (size_t n1 = 0; n1 < rlen; n1++) { for (size_t n2 = n1; n2 < rlen; n2++) { TString s1{request, 0, n1}; - TString s2{request, n1, n2 - n1}; - TString s3{request, n2, rlen - n2}; + TString s2{request, n1, n2 - n1}; + TString s3{request, n2, rlen - n2}; UNIT_ASSERT_EQUAL(s1 + s2 + s3, request); THttpRequestHeader httpRequestHeader; @@ -134,7 +134,7 @@ void THttpHeaderParserTestSuite::TestTrailingData() { TestStart(); THttpRequestHeader httpRequestHeader; UNIT_ASSERT(0 == httpHeaderParser->Init(&httpRequestHeader)); - const char* request = + const char* request = "GET /search?q=hi HTTP/1.1\r\n" "Host: www.google.ru:8080\r\n" "\r\n" @@ -156,7 +156,7 @@ void THttpHeaderParserTestSuite::TestProxyRequestHeader() { TestStart(); THttpRequestHeader httpRequestHeader; httpHeaderParser->Init(&httpRequestHeader); - const char* request = + const char* request = "GET http://www.google.ru:8080/search?q=hi HTTP/1.1\r\n" "X-Yandex-Response-Timeout: 1000\r\n" "X-Yandex-Request-Priority: 2\r\n" @@ -179,16 +179,16 @@ void THttpHeaderParserTestSuite::TestProxyRequestHeader() { UNIT_ASSERT_VALUES_EQUAL(httpRequestHeader.if_modified_since, TInstant::ParseIso8601Deprecated("1994-10-29 19:43:31Z").TimeT()); UNIT_ASSERT_EQUAL(httpRequestHeader.request_uri, - "http://www.google.ru:8080/search?q=hi"); - UNIT_ASSERT(httpRequestHeader.GetUrl() == + "http://www.google.ru:8080/search?q=hi"); + UNIT_ASSERT(httpRequestHeader.GetUrl() == "http://www.google.ru:8080/search?q=hi"); UNIT_ASSERT_EQUAL(strcmp(httpRequestHeader.host, ""), 0); UNIT_ASSERT_EQUAL(strcmp(httpRequestHeader.from, "webadmin@yandex.ru"), 0); UNIT_ASSERT_EQUAL(strcmp(httpRequestHeader.user_agent, - "Yandex/1.01.001 (compatible; Win16; I)"), - 0); + "Yandex/1.01.001 (compatible; Win16; I)"), + 0); UNIT_ASSERT_EQUAL(httpHeaderParser->lastchar - request + 1, - (i32)strlen(request)); + (i32)strlen(request)); TestFinish(); } @@ -196,8 +196,8 @@ void THttpHeaderParserTestSuite::TestIncorrectRequestHeader() { TestStart(); THttpRequestHeader httpRequestHeader; httpHeaderParser->Init(&httpRequestHeader); - const char* request = "GET /search?q=hi HTP/1.1\r\n" - "Host: www.google.ru:8080\r\n\r\n"; + const char* request = "GET /search?q=hi HTP/1.1\r\n" + "Host: www.google.ru:8080\r\n\r\n"; i32 result = httpHeaderParser->Execute(request, strlen(request)); UNIT_ASSERT(result != 2); TestFinish(); @@ -214,7 +214,7 @@ void THttpHeaderParserTestSuite::TestLastModified() { UNIT_ASSERT(2 == httpHeaderParser->Execute(headers, strlen(headers))); UNIT_ASSERT_VALUES_EQUAL( TInstant::ParseIso8601Deprecated("2009-08-13 14:27:08Z").TimeT(), - h.http_time); + h.http_time); TestFinish(); } @@ -235,7 +235,7 @@ void THttpHeaderParserTestSuite::TestXRobotsTagUnknownTags() { TestStart(); THttpHeader httpHeader; httpHeaderParser->Init(&httpHeader); - const char* headers = + const char* headers = "HTTP/1.1 200 OK\r\n" "Content-Type: text/html\r\n" "x-robots-tag: asdfasdf asdf asdf,,, , noindex,noodpXXX , NOFOLLOW ,noodpnofollow\r\n\r\n"; @@ -384,7 +384,7 @@ void THttpHeaderParserTestSuite::TestHreflang() { TestStart(); THttpHeader httpHeader; httpHeaderParser->Init(&httpHeader); - const char* headers = + const char* headers = "HTTP/1.1 200 OK\r\n" "Content-Type: text/html\r\n" "link: <http://www.high.ru/>; rel='alternate'; hreflang='x-default'\r\n" @@ -414,7 +414,7 @@ void THttpHeaderParserTestSuite::TestRelCanonical() { TestStart(); THttpHeader httpHeader; httpHeaderParser->Init(&httpHeader); - const char* headers = + const char* headers = "HTTP/1.1 200 OK\r\n" "Content-Type: text/html\r\n" "Link: <http://yandex.ru>; rel = \"canonical\"\r\n\r\n"; @@ -428,8 +428,8 @@ void THttpHeaderParserTestSuite::TestResponseHeaderOnRequest() { TestStart(); THttpHeader httpHeader; httpHeaderParser->Init(&httpHeader); - const char* request = "GET /search?q=hi HTP/1.1\r\n" - "Host: www.google.ru:8080\r\n\r\n"; + const char* request = "GET /search?q=hi HTP/1.1\r\n" + "Host: www.google.ru:8080\r\n\r\n"; i32 result = httpHeaderParser->Execute(request, strlen(request)); UNIT_ASSERT_EQUAL(result, -3); TestFinish(); @@ -439,9 +439,9 @@ void THttpHeaderParserTestSuite::TestRequestHeaderOnResponse() { TestStart(); THttpRequestHeader httpRequestHeader; httpHeaderParser->Init(&httpRequestHeader); - const char* response = "HTTP/1.1 200 OK\r\n" - "Content-Type: text/html\r\n" - "Last-Modified: Thu, 13 Aug 2009 14:\r\n\r\n"; + const char* response = "HTTP/1.1 200 OK\r\n" + "Content-Type: text/html\r\n" + "Last-Modified: Thu, 13 Aug 2009 14:\r\n\r\n"; i32 result = httpHeaderParser->Execute(response, strlen(response)); UNIT_ASSERT_EQUAL(result, -3); TestFinish(); @@ -451,13 +451,13 @@ void THttpHeaderParserTestSuite::TestMimeType() { TestStart(); THttpHeader httpHeader; httpHeaderParser->Init(&httpHeader); - const char* headers = + const char* headers = "HTTP/1.1 200 OK\r\n" "Content-Type: application/json; charset=utf-8\r\n\r\n"; i32 result = httpHeaderParser->Execute(headers, strlen(headers)); UNIT_ASSERT_EQUAL(result, 2); UNIT_ASSERT_EQUAL(httpHeader.mime_type, static_cast<ui8>(MIME_JSON)); - UNIT_ASSERT_EQUAL(httpHeader.charset, static_cast<ui8>(CODES_UTF8)); + UNIT_ASSERT_EQUAL(httpHeader.charset, static_cast<ui8>(CODES_UTF8)); TestFinish(); } @@ -516,10 +516,10 @@ Y_UNIT_TEST_SUITE(TestHttpChunkParser) { Y_UNIT_TEST(TestWithoutEolHead) { const TStringBuf blob{ "4\r\n" - "____\r\n"}; + "____\r\n"}; TVector<int> states{ - -1, /* 1, -1, - 1, -1, 1, -1, 1, -1 */}; + -1, /* 1, -1, + 1, -1, 1, -1, 1, -1 */}; // as soon as error happens parser state should be considered // undefined, state is meaningless after the very first `-1` // moreover, testenv produces `states[1] == -1` for this input and @@ -530,7 +530,7 @@ Y_UNIT_TEST_SUITE(TestHttpChunkParser) { Y_UNIT_TEST(TestTrivialChunk) { const TStringBuf blob{ "\r\n" - "4\r\n"}; + "4\r\n"}; THttpChunkParser parser(parseBytesWithLastState(blob, 2)); UNIT_ASSERT_EQUAL(parser.chunk_length, 4); UNIT_ASSERT_EQUAL(parser.cnt64, 4); @@ -539,18 +539,18 @@ Y_UNIT_TEST_SUITE(TestHttpChunkParser) { Y_UNIT_TEST(TestNegative) { const TStringBuf blob{ "\r\n" - "-1"}; + "-1"}; TVector<int> states{ 1, 1, - -1, - /* 1 */}; + -1, + /* 1 */}; parseByteByByte(blob, states); } Y_UNIT_TEST(TestLeadingZero) { const TStringBuf blob{ "\r\n" - "042\r\n"}; + "042\r\n"}; THttpChunkParser parser(parseBytesWithLastState(blob, 2)); UNIT_ASSERT_EQUAL(parser.chunk_length, 0x42); } @@ -558,7 +558,7 @@ Y_UNIT_TEST_SUITE(TestHttpChunkParser) { Y_UNIT_TEST(TestIntOverflow) { const TStringBuf blob{ "\r\n" - "deadbeef"}; + "deadbeef"}; THttpChunkParser parser(parseBytesWithLastState(blob, -2)); UNIT_ASSERT_EQUAL(parser.chunk_length, 0); UNIT_ASSERT_EQUAL(parser.cnt64, 0xdeadbeef); @@ -571,9 +571,9 @@ Y_UNIT_TEST_SUITE(TestHttpChunkParser) { "_" // first byte of the chunk }; TVector<int> states{ - 1, 1, - 1, 1, 2, - -1}; + 1, 1, + 1, 1, 2, + -1}; parseByteByByte(blob, states); } @@ -584,7 +584,7 @@ Y_UNIT_TEST_SUITE(TestHttpChunkParser) { "\r\n" "000 ;foo = bar \r\n" "Trailer: bar\r\n" - "\r\n"}; + "\r\n"}; THttpChunkParser parser(parseBytesWithLastState(blob, 2)); UNIT_ASSERT_EQUAL(parser.chunk_length, 0); } diff --git a/library/cpp/http/fetch/httpheader.h b/library/cpp/http/fetch/httpheader.h index e779cb08ec..b2810bbd41 100644 --- a/library/cpp/http/fetch/httpheader.h +++ b/library/cpp/http/fetch/httpheader.h @@ -10,33 +10,33 @@ #include <util/generic/ylimits.h> #include <util/system/maxlen.h> -#include <ctime> +#include <ctime> #include <cstdio> #include <cstdlib> #include <cstring> -#include <algorithm> +#include <algorithm> // This is ugly solution but here a lot of work to do it the right way. #define FETCHER_URL_MAX 8192 -extern const i64 DEFAULT_RETRY_AFTER; /// == -1 +extern const i64 DEFAULT_RETRY_AFTER; /// == -1 extern const i64 DEFAULT_IF_MODIFIED_SINCE; /// == -1 -extern const i32 DEFAULT_MAX_AGE; /// == -1 -extern const i8 DEFAULT_REQUEST_PRIORITY; /// == -1 -extern const i32 DEFAULT_RESPONSE_TIMEOUT; /// == -1 +extern const i32 DEFAULT_MAX_AGE; /// == -1 +extern const i8 DEFAULT_REQUEST_PRIORITY; /// == -1 +extern const i32 DEFAULT_RESPONSE_TIMEOUT; /// == -1 #define HTTP_PREFIX "http://" #define MAX_LANGREGION_LEN 4 #define MAXWORD_LEN 55 enum HTTP_COMPRESSION { - HTTP_COMPRESSION_UNSET = 0, - HTTP_COMPRESSION_ERROR = 1, + HTTP_COMPRESSION_UNSET = 0, + HTTP_COMPRESSION_ERROR = 1, HTTP_COMPRESSION_IDENTITY = 2, - HTTP_COMPRESSION_GZIP = 3, - HTTP_COMPRESSION_DEFLATE = 4, + HTTP_COMPRESSION_GZIP = 3, + HTTP_COMPRESSION_DEFLATE = 4, HTTP_COMPRESSION_COMPRESS = 5, - HTTP_COMPRESSION_MAX = 6 + HTTP_COMPRESSION_MAX = 6 }; enum HTTP_METHOD { @@ -61,22 +61,22 @@ enum HTTP_CONNECTION { /// Class represents general http header fields. struct THttpBaseHeader { public: - i16 error; - i32 header_size; - i32 entity_size; - i64 content_length; - i64 http_time; // seconds since epoch - i64 content_range_start; // Content-Range: first-byte-pos - i64 content_range_end; // Content-Range: last-byte-pos - i64 content_range_entity_length; // Content-Range: entity-length - i8 http_minor; - i8 mime_type; - i8 charset; - i8 compression_method; - i8 transfer_chunked; - i8 connection_closed; + i16 error; + i32 header_size; + i32 entity_size; + i64 content_length; + i64 http_time; // seconds since epoch + i64 content_range_start; // Content-Range: first-byte-pos + i64 content_range_end; // Content-Range: last-byte-pos + i64 content_range_entity_length; // Content-Range: entity-length + i8 http_minor; + i8 mime_type; + i8 charset; + i8 compression_method; + i8 transfer_chunked; + i8 connection_closed; TString base; - + public: void Init() { error = 0; @@ -113,8 +113,8 @@ public: } int SetBase(const char* path, - const char* hostNamePtr = nullptr, - int hostNameLength = 0) { + const char* hostNamePtr = nullptr, + int hostNameLength = 0) { if (*path == '/') { base = "http://"; base += TStringBuf(hostNamePtr, hostNameLength); @@ -130,16 +130,16 @@ enum { HREFLANG_MAX = FETCHER_URL_MAX * 2 }; /// Class represents Http Response Header. struct THttpHeader: public THttpBaseHeader { public: - i8 accept_ranges; - i8 squid_error; + i8 accept_ranges; + i8 squid_error; i8 x_robots_tag; // deprecated, use x_robots_state instead - i16 http_status; + i16 http_status; TString location; TString rel_canonical; - char hreflangs[HREFLANG_MAX]; - i64 retry_after; + char hreflangs[HREFLANG_MAX]; + i64 retry_after; TString x_robots_state; // 'xxxxx' format, see `library/html/zoneconf/parsefunc.cpp` - + public: void Init() { THttpBaseHeader::Init(); @@ -174,12 +174,12 @@ public: char x_yandex_sourcename[MAXWORD_LEN]; char x_yandex_requesttype[MAXWORD_LEN]; char x_yandex_fetchoptions[MAXWORD_LEN]; - i8 http_method; - i8 x_yandex_request_priority; - i32 x_yandex_response_timeout; - i32 max_age; - i64 if_modified_since; - + i8 http_method; + i8 x_yandex_request_priority; + i32 x_yandex_response_timeout; + i32 max_age; + i64 if_modified_since; + public: THttpRequestHeader() { Init(); @@ -229,7 +229,7 @@ public: return url; } - char* GetUrl(char* buffer, size_t size) { + char* GetUrl(char* buffer, size_t size) { if (host[0] == 0 || !strcmp(host, "")) { strlcpy(buffer, request_uri.c_str(), size); } else { @@ -244,27 +244,27 @@ public: char* realm; char* nonce; char* opaque; - bool stale; - int algorithm; - bool qop_auth; - bool use_auth; + bool stale; + int algorithm; + bool qop_auth; + bool use_auth; //we do not provide auth-int variant as too heavy //bool qop_auth_int; - THttpAuthHeader() - : realm(nullptr) - , nonce(nullptr) - , opaque(nullptr) - , stale(false) - , algorithm(0) - , qop_auth(false) - , use_auth(true) + THttpAuthHeader() + : realm(nullptr) + , nonce(nullptr) + , opaque(nullptr) + , stale(false) + , algorithm(0) + , qop_auth(false) + , use_auth(true) { THttpHeader::Init(); } - ~THttpAuthHeader() { + ~THttpAuthHeader() { free(realm); free(nonce); free(opaque); @@ -272,7 +272,7 @@ public: void Print() { THttpHeader::Print(); - if (use_auth) { + if (use_auth) { if (realm) printf("realm: \"%s\"\n", realm); if (nonce) diff --git a/library/cpp/http/fetch/httpload.cpp b/library/cpp/http/fetch/httpload.cpp index 975a8d792c..82ea8900b5 100644 --- a/library/cpp/http/fetch/httpload.cpp +++ b/library/cpp/http/fetch/httpload.cpp @@ -2,210 +2,210 @@ /************************************************************/ /************************************************************/ -httpAgentReader::httpAgentReader(httpSpecialAgent& agent, - const char* baseUrl, - bool assumeConnectionClosed, - bool use_auth, - int bufSize) - : Header_() - , Agent_(agent) - , Buffer_(new char[bufSize]) - , BufPtr_(Buffer_) - , BufSize_(bufSize) - , BufRest_(0) +httpAgentReader::httpAgentReader(httpSpecialAgent& agent, + const char* baseUrl, + bool assumeConnectionClosed, + bool use_auth, + int bufSize) + : Header_() + , Agent_(agent) + , Buffer_(new char[bufSize]) + , BufPtr_(Buffer_) + , BufSize_(bufSize) + , BufRest_(0) { HeadRequest = false; - Header = &Header_; + Header = &Header_; if (use_auth) - HeaderParser.Init(&Header_); + HeaderParser.Init(&Header_); else HeaderParser.Init(Header); - setAssumeConnectionClosed(assumeConnectionClosed ? 1 : 0); - Header_.SetBase(baseUrl); + setAssumeConnectionClosed(assumeConnectionClosed ? 1 : 0); + Header_.SetBase(baseUrl); - if (Header_.error) + if (Header_.error) State = hp_error; else State = hp_in_header; } /************************************************************/ -httpAgentReader::~httpAgentReader() { - delete[] Buffer_; +httpAgentReader::~httpAgentReader() { + delete[] Buffer_; } /************************************************************/ -void httpAgentReader::readBuf() { - assert(BufRest_ == 0); - if (!BufPtr_) { - BufRest_ = -1; +void httpAgentReader::readBuf() { + assert(BufRest_ == 0); + if (!BufPtr_) { + BufRest_ = -1; return; } - BufRest_ = Agent_.read(Buffer_, BufSize_); - if (BufRest_ <= 0) { - BufRest_ = -1; - BufPtr_ = nullptr; + BufRest_ = Agent_.read(Buffer_, BufSize_); + if (BufRest_ <= 0) { + BufRest_ = -1; + BufPtr_ = nullptr; } else { - BufPtr_ = Buffer_; - + BufPtr_ = Buffer_; + //cout << "BUF: " << mBuffer << endl << endl; } } /************************************************************/ -const THttpHeader* httpAgentReader::readHeader() { - while (State == hp_in_header) { - if (!step()) { - Header_.error = HTTP_CONNECTION_LOST; +const THttpHeader* httpAgentReader::readHeader() { + while (State == hp_in_header) { + if (!step()) { + Header_.error = HTTP_CONNECTION_LOST; return nullptr; } - ParseGeneric(BufPtr_, BufRest_); + ParseGeneric(BufPtr_, BufRest_); } - if (State == hp_eof || State == hp_error) { + if (State == hp_eof || State == hp_error) { BufPtr_ = nullptr; - BufRest_ = -1; + BufRest_ = -1; } - if (State == hp_error || Header_.error) + if (State == hp_error || Header_.error) return nullptr; - return &Header_; + return &Header_; } /************************************************************/ -long httpAgentReader::readPortion(void*& buf) { - assert(State != hp_in_header); +long httpAgentReader::readPortion(void*& buf) { + assert(State != hp_in_header); long Chunk = 0; - do { - if (BufSize_ == 0 && !BufPtr_) + do { + if (BufSize_ == 0 && !BufPtr_) return 0; if (!step()) return 0; - Chunk = ParseGeneric(BufPtr_, BufRest_); - buf = BufPtr_; + Chunk = ParseGeneric(BufPtr_, BufRest_); + buf = BufPtr_; - if (State == hp_error && Header_.entity_size > Header_.content_length) { - Chunk -= (Header_.entity_size - Header_.content_length); - BufPtr_ = (char*)BufPtr_ + Chunk; - BufRest_ = 0; - State = hp_eof; - Header_.error = 0; + if (State == hp_error && Header_.entity_size > Header_.content_length) { + Chunk -= (Header_.entity_size - Header_.content_length); + BufPtr_ = (char*)BufPtr_ + Chunk; + BufRest_ = 0; + State = hp_eof; + Header_.error = 0; break; } - BufPtr_ = (char*)BufPtr_ + Chunk; - BufRest_ -= Chunk; + BufPtr_ = (char*)BufPtr_ + Chunk; + BufRest_ -= Chunk; - if (State == hp_eof || State == hp_error) { - BufRest_ = -1; - BufPtr_ = nullptr; + if (State == hp_eof || State == hp_error) { + BufRest_ = -1; + BufPtr_ = nullptr; } } while (!Chunk); return Chunk; } /************************************************************/ -bool httpAgentReader::skipTheRest() { +bool httpAgentReader::skipTheRest() { void* b; while (!eof()) readPortion(b); - return (State == hp_eof); + return (State == hp_eof); } /************************************************************/ /************************************************************/ -httpLoadAgent::httpLoadAgent(bool handleAuthorization, - socketHandlerFactory& factory) - : Factory_(factory) - , HandleAuthorization_(handleAuthorization) - , URL_() - , PersistentConn_(false) - , Reader_(nullptr) - , Headers_() - , ErrCode_(0) - , RealHost_(nullptr) +httpLoadAgent::httpLoadAgent(bool handleAuthorization, + socketHandlerFactory& factory) + : Factory_(factory) + , HandleAuthorization_(handleAuthorization) + , URL_() + , PersistentConn_(false) + , Reader_(nullptr) + , Headers_() + , ErrCode_(0) + , RealHost_(nullptr) { } /************************************************************/ -httpLoadAgent::~httpLoadAgent() { - delete Reader_; - free(RealHost_); +httpLoadAgent::~httpLoadAgent() { + delete Reader_; + free(RealHost_); } /************************************************************/ -void httpLoadAgent::clearReader() { - if (Reader_) { +void httpLoadAgent::clearReader() { + if (Reader_) { bool opened = false; - if (PersistentConn_) { - const THttpHeader* H = Reader_->readHeader(); - if (H && !H->connection_closed) { - Reader_->skipTheRest(); + if (PersistentConn_) { + const THttpHeader* H = Reader_->readHeader(); + if (H && !H->connection_closed) { + Reader_->skipTheRest(); opened = true; } } if (!opened) Disconnect(); - delete Reader_; + delete Reader_; Reader_ = nullptr; } - ErrCode_ = 0; + ErrCode_ = 0; } /************************************************************/ -void httpLoadAgent::setRealHost(const char* hostname) { - free(RealHost_); +void httpLoadAgent::setRealHost(const char* hostname) { + free(RealHost_); if (hostname) - RealHost_ = strdup(hostname); + RealHost_ = strdup(hostname); else RealHost_ = nullptr; - ErrCode_ = 0; + ErrCode_ = 0; } /************************************************************/ -void httpLoadAgent::setIMS(const char* ifModifiedSince) { +void httpLoadAgent::setIMS(const char* ifModifiedSince) { char ims_buf[100]; snprintf(ims_buf, 100, "If-Modified-Since: %s\r\n", ifModifiedSince); - Headers_.push_back(ims_buf); + Headers_.push_back(ims_buf); } /************************************************************/ -void httpLoadAgent::addHeaderInstruction(const char* instr) { - Headers_.push_back(instr); +void httpLoadAgent::addHeaderInstruction(const char* instr) { + Headers_.push_back(instr); } /************************************************************/ -void httpLoadAgent::dropHeaderInstructions() { - Headers_.clear(); +void httpLoadAgent::dropHeaderInstructions() { + Headers_.clear(); } /************************************************************/ -bool httpLoadAgent::startRequest(const THttpURL& url, - bool persistent, - const TAddrList& addrs) +bool httpLoadAgent::startRequest(const THttpURL& url, + bool persistent, + const TAddrList& addrs) { clearReader(); - ErrCode_ = 0; + ErrCode_ = 0; - URL_.Clear(); - URL_ = url; - PersistentConn_ = persistent; - if (!URL_.IsValidAbs()) + URL_.Clear(); + URL_ = url; + PersistentConn_ = persistent; + if (!URL_.IsValidAbs()) return false; - if (!HandleAuthorization_ && !URL_.IsNull(THttpURL::FlagAuth)) + if (!HandleAuthorization_ && !URL_.IsNull(THttpURL::FlagAuth)) return false; return doSetHost(addrs) && doStartRequest(); } /************************************************************/ -bool httpLoadAgent::startRequest(const char* url, - const char* url_to_merge, - bool persistent, - const TAddrList& addrs) { +bool httpLoadAgent::startRequest(const char* url, + const char* url_to_merge, + bool persistent, + const TAddrList& addrs) { clearReader(); URL_.Clear(); @@ -222,116 +222,116 @@ bool httpLoadAgent::startRequest(const char* url, } /************************************************************/ -bool httpLoadAgent::startRequest(const char* url, - const char* url_to_merge, - bool persistent, - ui32 ip) { +bool httpLoadAgent::startRequest(const char* url, + const char* url_to_merge, + bool persistent, + ui32 ip) { clearReader(); - URL_.Clear(); - PersistentConn_ = persistent; + URL_.Clear(); + PersistentConn_ = persistent; long flags = THttpURL::FeatureSchemeKnown | THttpURL::FeaturesNormalizeSet; - if (HandleAuthorization_) + if (HandleAuthorization_) flags |= THttpURL::FeatureAuthSupported; - if (URL_.Parse(url, flags, url_to_merge) || !URL_.IsValidGlobal()) + if (URL_.Parse(url, flags, url_to_merge) || !URL_.IsValidGlobal()) return false; return doSetHost(TAddrList::MakeV4Addr(ip, URL_.GetPort())) && doStartRequest(); } /************************************************************/ -bool httpLoadAgent::doSetHost(const TAddrList& addrs) { - socketAbstractHandler* h = Factory_.chooseHandler(URL_); +bool httpLoadAgent::doSetHost(const TAddrList& addrs) { + socketAbstractHandler* h = Factory_.chooseHandler(URL_); if (!h) return false; Socket.setHandler(h); - if (addrs.size()) { - ErrCode_ = SetHost(URL_.Get(THttpURL::FieldHost), + if (addrs.size()) { + ErrCode_ = SetHost(URL_.Get(THttpURL::FieldHost), URL_.GetPort(), addrs); } else { - ErrCode_ = SetHost(URL_.Get(THttpURL::FieldHost), - URL_.GetPort()); + ErrCode_ = SetHost(URL_.Get(THttpURL::FieldHost), + URL_.GetPort()); } - if (ErrCode_) + if (ErrCode_) return false; - if (RealHost_) { + if (RealHost_) { free(Hostheader); - Hostheader = (char*)malloc(strlen(RealHost_) + 20); - sprintf(Hostheader, "Host: %s\r\n", RealHost_); + Hostheader = (char*)malloc(strlen(RealHost_) + 20); + sprintf(Hostheader, "Host: %s\r\n", RealHost_); } - if (!URL_.IsNull(THttpURL::FlagAuth)) { - if (!HandleAuthorization_) { - ErrCode_ = HTTP_UNAUTHORIZED; + if (!URL_.IsNull(THttpURL::FlagAuth)) { + if (!HandleAuthorization_) { + ErrCode_ = HTTP_UNAUTHORIZED; return false; } - Digest_.setAuthorization(URL_.Get(THttpURL::FieldUsername), - URL_.Get(THttpURL::FieldPassword)); + Digest_.setAuthorization(URL_.Get(THttpURL::FieldUsername), + URL_.Get(THttpURL::FieldPassword)); } return true; } /************************************************************/ -bool httpLoadAgent::setHost(const char* host_url, - const TAddrList& addrs) { +bool httpLoadAgent::setHost(const char* host_url, + const TAddrList& addrs) { clearReader(); - URL_.Clear(); - PersistentConn_ = true; + URL_.Clear(); + PersistentConn_ = true; long flags = THttpURL::FeatureSchemeKnown | THttpURL::FeaturesNormalizeSet; - if (HandleAuthorization_) + if (HandleAuthorization_) flags |= THttpURL::FeatureAuthSupported; - if (URL_.Parse(host_url, flags) || !URL_.IsValidGlobal()) + if (URL_.Parse(host_url, flags) || !URL_.IsValidGlobal()) return false; return doSetHost(addrs); } /************************************************************/ -bool httpLoadAgent::startOneRequest(const char* local_url) { +bool httpLoadAgent::startOneRequest(const char* local_url) { clearReader(); THttpURL lURL; - if (lURL.Parse(local_url, THttpURL::FeaturesNormalizeSet) || lURL.IsValidGlobal()) + if (lURL.Parse(local_url, THttpURL::FeaturesNormalizeSet) || lURL.IsValidGlobal()) return false; - URL_.SetInMemory(THttpURL::FieldPath, lURL.Get(THttpURL::FieldPath)); - URL_.SetInMemory(THttpURL::FieldQuery, lURL.Get(THttpURL::FieldQuery)); - URL_.Rewrite(); + URL_.SetInMemory(THttpURL::FieldPath, lURL.Get(THttpURL::FieldPath)); + URL_.SetInMemory(THttpURL::FieldQuery, lURL.Get(THttpURL::FieldQuery)); + URL_.Rewrite(); return doStartRequest(); } /************************************************************/ -bool httpLoadAgent::doStartRequest() { - TString urlStr = URL_.PrintS(THttpURL::FlagPath | THttpURL::FlagQuery); +bool httpLoadAgent::doStartRequest() { + TString urlStr = URL_.PrintS(THttpURL::FlagPath | THttpURL::FlagQuery); if (!urlStr) urlStr = "/"; - for (int step = 0; step < 10; step++) { - const char* digestHeader = Digest_.getHeaderInstruction(); + for (int step = 0; step < 10; step++) { + const char* digestHeader = Digest_.getHeaderInstruction(); - unsigned i = (digestHeader) ? 2 : 1; + unsigned i = (digestHeader) ? 2 : 1; const char** headers = - (const char**)(alloca((i + Headers_.size()) * sizeof(char*))); + (const char**)(alloca((i + Headers_.size()) * sizeof(char*))); - for (i = 0; i < Headers_.size(); i++) - headers[i] = Headers_[i].c_str(); + for (i = 0; i < Headers_.size(); i++) + headers[i] = Headers_[i].c_str(); if (digestHeader) headers[i++] = digestHeader; - headers[i] = nullptr; + headers[i] = nullptr; - ErrCode_ = RequestGet(urlStr.c_str(), headers, PersistentConn_); + ErrCode_ = RequestGet(urlStr.c_str(), headers, PersistentConn_); - if (ErrCode_) { + if (ErrCode_) { Disconnect(); return false; } @@ -339,20 +339,20 @@ bool httpLoadAgent::doStartRequest() { TString urlBaseStr = URL_.PrintS(THttpURL::FlagNoFrag); clearReader(); - Reader_ = new httpAgentReader(*this, urlBaseStr.c_str(), - !PersistentConn_, !Digest_.empty()); + Reader_ = new httpAgentReader(*this, urlBaseStr.c_str(), + !PersistentConn_, !Digest_.empty()); - if (Reader_->readHeader()) { + if (Reader_->readHeader()) { //mReader->getHeader()->Print(); - if (getHeader()->http_status == HTTP_UNAUTHORIZED && - step < 1 && - Digest_.processHeader(getAuthHeader(), - urlStr.c_str(), - "GET")) { + if (getHeader()->http_status == HTTP_UNAUTHORIZED && + step < 1 && + Digest_.processHeader(getAuthHeader(), + urlStr.c_str(), + "GET")) { //mReader->skipTheRest(); - delete Reader_; + delete Reader_; Reader_ = nullptr; - ErrCode_ = 0; + ErrCode_ = 0; Disconnect(); continue; } @@ -365,7 +365,7 @@ bool httpLoadAgent::doStartRequest() { return false; } - ErrCode_ = HTTP_UNAUTHORIZED; + ErrCode_ = HTTP_UNAUTHORIZED; return false; } diff --git a/library/cpp/http/fetch/httpload.h b/library/cpp/http/fetch/httpload.h index 5fc03d4be8..e22e4b809e 100644 --- a/library/cpp/http/fetch/httpload.h +++ b/library/cpp/http/fetch/httpload.h @@ -1,9 +1,9 @@ #pragma once -#include "httpagent.h" -#include "httpparser.h" -#include "http_digest.h" - +#include "httpagent.h" +#include "httpparser.h" +#include "http_digest.h" + #include <util/system/compat.h> #include <util/string/vector.h> #include <util/network/ip.h> @@ -20,7 +20,7 @@ /********************************************************/ // This class is used as a base one for flexible // socket handling -class socketAbstractHandler { +class socketAbstractHandler { public: virtual bool Good() = 0; @@ -36,12 +36,12 @@ public: virtual ssize_t read(void* buffer, ssize_t buflen) = 0; - virtual ~socketAbstractHandler() { - } + virtual ~socketAbstractHandler() { + } protected: - socketAbstractHandler() { - } + socketAbstractHandler() { + } }; /********************************************************/ @@ -49,54 +49,54 @@ protected: // socketAbstractHandler // (it is used by template scheme, // so it does not have virtual methods) -class TSocketHandlerPtr { +class TSocketHandlerPtr { protected: - socketAbstractHandler* Handler_; + socketAbstractHandler* Handler_; public: - TSocketHandlerPtr() - : Handler_(nullptr) - { - } + TSocketHandlerPtr() + : Handler_(nullptr) + { + } - virtual ~TSocketHandlerPtr() { - delete Handler_; - } + virtual ~TSocketHandlerPtr() { + delete Handler_; + } - int Good() { - return (Handler_ && Handler_->Good()); - } + int Good() { + return (Handler_ && Handler_->Good()); + } - int Connect(const TAddrList& addrs, TDuration Timeout) { - return (Handler_) ? Handler_->Connect(addrs, Timeout) : 1; + int Connect(const TAddrList& addrs, TDuration Timeout) { + return (Handler_) ? Handler_->Connect(addrs, Timeout) : 1; } - void Disconnect() { - if (Handler_) - Handler_->Disconnect(); + void Disconnect() { + if (Handler_) + Handler_->Disconnect(); } - void shutdown() { - if (Handler_) - Handler_->shutdown(); + void shutdown() { + if (Handler_) + Handler_->shutdown(); } - bool send(const char* message, ssize_t messlen) { - return (Handler_) ? Handler_->send(message, messlen) : false; + bool send(const char* message, ssize_t messlen) { + return (Handler_) ? Handler_->send(message, messlen) : false; } - virtual bool peek() { - return (Handler_) ? Handler_->peek() : false; + virtual bool peek() { + return (Handler_) ? Handler_->peek() : false; } - virtual ssize_t read(void* buffer, ssize_t buflen) { - return (Handler_) ? Handler_->read(buffer, buflen) : 0; + virtual ssize_t read(void* buffer, ssize_t buflen) { + return (Handler_) ? Handler_->read(buffer, buflen) : 0; } - void setHandler(socketAbstractHandler* handler) { - if (Handler_) - delete Handler_; - Handler_ = handler; + void setHandler(socketAbstractHandler* handler) { + if (Handler_) + delete Handler_; + Handler_ = handler; } }; @@ -108,58 +108,58 @@ using httpSpecialAgent = THttpAgent<TSocketHandlerPtr>; /********************************************************/ // Regular handler is used as implementation of // socketAbstractHandler for work through HTTP protocol -class socketRegularHandler: public socketAbstractHandler { -protected: - TSimpleSocketHandler Socket_; +class socketRegularHandler: public socketAbstractHandler { +protected: + TSimpleSocketHandler Socket_; -public: - socketRegularHandler() - : Socket_() - { - } +public: + socketRegularHandler() + : Socket_() + { + } - bool Good() override { - return Socket_.Good(); + bool Good() override { + return Socket_.Good(); } - int Connect(const TAddrList& addrs, TDuration Timeout) override { + int Connect(const TAddrList& addrs, TDuration Timeout) override { return Socket_.Connect(addrs, Timeout); } - void Disconnect() override { - Socket_.Disconnect(); + void Disconnect() override { + Socket_.Disconnect(); } - void shutdown() override { + void shutdown() override { //Do not block writing to socket //There are servers that works in a bad way with this //mSocket.shutdown(); } - bool send(const char* message, ssize_t messlen) override { - return Socket_.send(message, messlen); + bool send(const char* message, ssize_t messlen) override { + return Socket_.send(message, messlen); } - bool peek() override { - return Socket_.peek(); + bool peek() override { + return Socket_.peek(); } - ssize_t read(void* buffer, ssize_t buflen) override { - return Socket_.read(buffer, buflen); + ssize_t read(void* buffer, ssize_t buflen) override { + return Socket_.read(buffer, buflen); } }; /********************************************************/ // The base factory that allows to choose an appropriate // socketAbstractHandler implementation by url schema - -class socketHandlerFactory { -public: - virtual ~socketHandlerFactory() { - } + +class socketHandlerFactory { +public: + virtual ~socketHandlerFactory() { + } //returns mHandler_HTTP for correct HTTP-based url - virtual socketAbstractHandler* chooseHandler(const THttpURL& url); + virtual socketAbstractHandler* chooseHandler(const THttpURL& url); static socketHandlerFactory sInstance; }; @@ -168,138 +168,138 @@ public: // Section 2: the configurates tool to parse an HTTP-response /********************************************************/ -class httpAgentReader: public THttpParserGeneric<1> { -protected: - THttpAuthHeader Header_; - httpSpecialAgent& Agent_; +class httpAgentReader: public THttpParserGeneric<1> { +protected: + THttpAuthHeader Header_; + httpSpecialAgent& Agent_; - char* Buffer_; - void* BufPtr_; - int BufSize_; - long BufRest_; + char* Buffer_; + void* BufPtr_; + int BufSize_; + long BufRest_; void readBuf(); - bool step() { - if (BufRest_ == 0) + bool step() { + if (BufRest_ == 0) readBuf(); if (eof()) return false; return true; } -public: - httpAgentReader(httpSpecialAgent& agent, - const char* baseUrl, - bool assumeConnectionClosed, - bool use_auth = false, - int bufSize = 0x1000); +public: + httpAgentReader(httpSpecialAgent& agent, + const char* baseUrl, + bool assumeConnectionClosed, + bool use_auth = false, + int bufSize = 0x1000); ~httpAgentReader(); - bool eof() { - return BufRest_ < 0; + bool eof() { + return BufRest_ < 0; } - int error() { - return Header_.error; + int error() { + return Header_.error; } - void setError(int errCode) { - Header_.error = errCode; + void setError(int errCode) { + Header_.error = errCode; } - const THttpAuthHeader* getAuthHeader() { - return &Header_; + const THttpAuthHeader* getAuthHeader() { + return &Header_; } - const THttpHeader* readHeader(); - long readPortion(void*& buf); - bool skipTheRest(); + const THttpHeader* readHeader(); + long readPortion(void*& buf); + bool skipTheRest(); }; /********************************************************/ // Section 3: the main class /********************************************************/ -class httpLoadAgent: public httpSpecialAgent { -protected: - socketHandlerFactory& Factory_; - bool HandleAuthorization_; - THttpURL URL_; - bool PersistentConn_; - httpAgentReader* Reader_; - TVector<TString> Headers_; - int ErrCode_; - char* RealHost_; - httpDigestHandler Digest_; +class httpLoadAgent: public httpSpecialAgent { +protected: + socketHandlerFactory& Factory_; + bool HandleAuthorization_; + THttpURL URL_; + bool PersistentConn_; + httpAgentReader* Reader_; + TVector<TString> Headers_; + int ErrCode_; + char* RealHost_; + httpDigestHandler Digest_; void clearReader(); bool doSetHost(const TAddrList& addrs); bool doStartRequest(); -public: - httpLoadAgent(bool handleAuthorization = false, - socketHandlerFactory& factory = socketHandlerFactory::sInstance); +public: + httpLoadAgent(bool handleAuthorization = false, + socketHandlerFactory& factory = socketHandlerFactory::sInstance); ~httpLoadAgent(); void setRealHost(const char* host); - void setIMS(const char* ifModifiedSince); + void setIMS(const char* ifModifiedSince); void addHeaderInstruction(const char* instr); void dropHeaderInstructions(); bool startRequest(const char* url, const char* url_to_merge = nullptr, - bool persistent = false, + bool persistent = false, const TAddrList& addrs = TAddrList()); // deprecated v4-only bool startRequest(const char* url, const char* url_to_merge, - bool persistent, - ui32 ip); + bool persistent, + ui32 ip); bool startRequest(const THttpURL& url, - bool persistent = false, + bool persistent = false, const TAddrList& addrs = TAddrList()); - bool setHost(const char* host_url, - const TAddrList& addrs = TAddrList()); + bool setHost(const char* host_url, + const TAddrList& addrs = TAddrList()); bool startOneRequest(const char* local_url); - const THttpAuthHeader* getAuthHeader() { - if (Reader_ && Reader_->getAuthHeader()->use_auth) - return Reader_->getAuthHeader(); + const THttpAuthHeader* getAuthHeader() { + if (Reader_ && Reader_->getAuthHeader()->use_auth) + return Reader_->getAuthHeader(); return nullptr; } - const THttpHeader* getHeader() { - if (Reader_) - return Reader_->getAuthHeader(); + const THttpHeader* getHeader() { + if (Reader_) + return Reader_->getAuthHeader(); return nullptr; } - const THttpURL& getURL() { - return URL_; + const THttpURL& getURL() { + return URL_; } - bool eof() { - if (Reader_) - return Reader_->eof(); + bool eof() { + if (Reader_) + return Reader_->eof(); return true; } - int error() { - if (ErrCode_) - return ErrCode_; - if (Reader_) - return Reader_->error(); + int error() { + if (ErrCode_) + return ErrCode_; + if (Reader_) + return Reader_->error(); return HTTP_BAD_URL; } - long readPortion(void*& buf) { - if (Reader_) - return Reader_->readPortion(buf); + long readPortion(void*& buf) { + if (Reader_) + return Reader_->readPortion(buf); return -1; } }; diff --git a/library/cpp/http/fetch/httpparser.h b/library/cpp/http/fetch/httpparser.h index 989409bdd2..769828e4ae 100644 --- a/library/cpp/http/fetch/httpparser.h +++ b/library/cpp/http/fetch/httpparser.h @@ -6,22 +6,22 @@ #include <library/cpp/mime/types/mime.h> #include <util/system/yassert.h> #include <library/cpp/http/misc/httpcodes.h> - -template <size_t headermax = 100 << 10, size_t bodymax = 1 << 20> + +template <size_t headermax = 100 << 10, size_t bodymax = 1 << 20> struct TFakeCheck { - bool Check(THttpHeader* /*header*/) { - return false; - } - void CheckDocPart(void* /*buf*/, size_t /*len*/, THttpHeader* /*header*/) { - } //for every part of DocumentBody will be called - void CheckEndDoc(THttpHeader* /*header*/) { - } - size_t GetMaxHeaderSize() { - return headermax; - } - size_t GetMaxBodySize(THttpHeader*) { - return bodymax; - } + bool Check(THttpHeader* /*header*/) { + return false; + } + void CheckDocPart(void* /*buf*/, size_t /*len*/, THttpHeader* /*header*/) { + } //for every part of DocumentBody will be called + void CheckEndDoc(THttpHeader* /*header*/) { + } + size_t GetMaxHeaderSize() { + return headermax; + } + size_t GetMaxBodySize(THttpHeader*) { + return bodymax; + } }; class THttpParserBase { @@ -37,17 +37,17 @@ public: hp_read_chunk }; - States GetState() { - return State; - } + States GetState() { + return State; + } - void setAssumeConnectionClosed(int value) { + void setAssumeConnectionClosed(int value) { AssumeConnectionClosed = value; } - THttpHeader* GetHttpHeader() const { - return Header; - } + THttpHeader* GetHttpHeader() const { + return Header; + } protected: int CheckHeaders() { @@ -69,8 +69,8 @@ protected: if (Header->compression_method != HTTP_COMPRESSION_UNSET && Header->compression_method != HTTP_COMPRESSION_IDENTITY && Header->compression_method != HTTP_COMPRESSION_GZIP && - Header->compression_method != HTTP_COMPRESSION_DEFLATE) - { + Header->compression_method != HTTP_COMPRESSION_DEFLATE) + { Header->error = HTTP_BAD_CONTENT_ENCODING; return 1; } @@ -78,7 +78,7 @@ protected: if (Header->connection_closed == -1) Header->connection_closed = (Header->http_minor == 0 || AssumeConnectionClosed); - if (!Header->transfer_chunked && !Header->connection_closed && Header->content_length < 0 && !HeadRequest) { + if (!Header->transfer_chunked && !Header->connection_closed && Header->content_length < 0 && !HeadRequest) { Header->error = HTTP_LENGTH_UNKNOWN; return 1; } @@ -93,15 +93,15 @@ protected: THttpChunkParser ChunkParser; States State; long ChunkSize; - THttpHeader* Header; + THttpHeader* Header; int AssumeConnectionClosed; bool HeadRequest; }; -template <int isReader, typename TCheck = TFakeCheck<>> +template <int isReader, typename TCheck = TFakeCheck<>> class THttpParserGeneric: public THttpParserBase, public TCheck { protected: - long ParseGeneric(void*& buf, long& size) { + long ParseGeneric(void*& buf, long& size) { if (!size) { switch (State) { case hp_error: @@ -155,10 +155,10 @@ protected: size -= long(HeaderParser.lastchar - (char*)buf + 1); buf = HeaderParser.lastchar + 1; State = CheckHeaders() ? hp_error - : Header->transfer_chunked ? hp_begin_chunk_header - : Header->content_length == 0 ? hp_eof - : Header->content_length > 0 ? hp_read_alive - : hp_read_closed; + : Header->transfer_chunked ? hp_begin_chunk_header + : Header->content_length == 0 ? hp_eof + : Header->content_length > 0 ? hp_read_alive + : hp_read_closed; if (State == hp_begin_chunk_header) { // unget \n for chunk reader buf = (char*)buf - 1; @@ -239,11 +239,11 @@ protected: } }; -template <class TCheck = TFakeCheck<>> +template <class TCheck = TFakeCheck<>> class THttpParser: public THttpParserGeneric<0, TCheck> { typedef THttpParserGeneric<0, TCheck> TBaseT; //sorry avoiding gcc 3.4.6 BUG! public: - void Init(THttpHeader* H, bool head_request = false) { + void Init(THttpHeader* H, bool head_request = false) { TBaseT::Header = H; TBaseT::HeaderParser.Init(TBaseT::Header); TBaseT::State = TBaseT::hp_in_header; @@ -251,19 +251,19 @@ public: TBaseT::HeadRequest = head_request; } - void Parse(void* buf, long size) { + void Parse(void* buf, long size) { TBaseT::ParseGeneric(buf, size); } }; class TMemoReader { public: - int Init(void* buf, long bufsize) { + int Init(void* buf, long bufsize) { Buf = buf; Bufsize = bufsize; return 0; } - long Read(void*& buf) { + long Read(void*& buf) { Y_ASSERT(Bufsize >= 0); if (!Bufsize) { Bufsize = -1; @@ -277,15 +277,15 @@ public: protected: long Bufsize; - void* Buf; + void* Buf; }; template <class Reader> class THttpReader: public THttpParserGeneric<1>, public Reader { typedef THttpParserGeneric<1> TBaseT; - + public: - using TBaseT::AssumeConnectionClosed; + using TBaseT::AssumeConnectionClosed; using TBaseT::Header; using TBaseT::ParseGeneric; using TBaseT::State; @@ -299,7 +299,7 @@ public: return parsHeader ? ParseHeader() : SkipHeader(); } - long Read(void*& buf) { + long Read(void*& buf) { long Chunk; do { if (!Size) { @@ -317,7 +317,7 @@ public: if (State == hp_eof) { Size = 0; Eoferr = 0; - } else if (State == hp_error) + } else if (State == hp_error) return Eoferr = -1; } while (!Chunk); return Chunk; @@ -352,9 +352,9 @@ protected: hdrsize -= Size; } State = Header->transfer_chunked ? hp_begin_chunk_header - : Header->content_length == 0 ? hp_eof - : Header->content_length > 0 ? hp_read_alive - : hp_read_closed; + : Header->content_length == 0 ? hp_eof + : Header->content_length > 0 ? hp_read_alive + : hp_read_closed; Header->entity_size = 0; if (State == hp_eof) Eoferr = 0; @@ -366,7 +366,7 @@ protected: return 0; } - void* Ptr; + void* Ptr; long Size; - int Eoferr; + int Eoferr; }; diff --git a/library/cpp/http/fetch/httpparser_ut.cpp b/library/cpp/http/fetch/httpparser_ut.cpp index 6957eb2f5f..3b3b938e7a 100644 --- a/library/cpp/http/fetch/httpparser_ut.cpp +++ b/library/cpp/http/fetch/httpparser_ut.cpp @@ -2,13 +2,13 @@ #include <library/cpp/testing/unittest/registar.h> -#define ENUM_OUT(arg) \ - case type ::arg: { \ - out << #arg; \ - return; \ - } +#define ENUM_OUT(arg) \ + case type ::arg: { \ + out << #arg; \ + return; \ + } -template <> +template <> void Out<THttpParserBase::States>(IOutputStream& out, THttpParserBase::States st) { using type = THttpParserBase::States; switch (st) { @@ -24,27 +24,27 @@ void Out<THttpParserBase::States>(IOutputStream& out, THttpParserBase::States st } namespace { - class TSomethingLikeFakeCheck; + class TSomethingLikeFakeCheck; - using TTestHttpParser = THttpParser<TSomethingLikeFakeCheck>; + using TTestHttpParser = THttpParser<TSomethingLikeFakeCheck>; - class TSomethingLikeFakeCheck { - TString Body_; + class TSomethingLikeFakeCheck { + TString Body_; - public: - const TString& Body() const { - return Body_; - } + public: + const TString& Body() const { + return Body_; + } - // other functions are not really called by THttpParser - void CheckDocPart(const void* buf, size_t len, THttpHeader* /* header */) { - TString s(static_cast<const char*>(buf), len); - Cout << "State = " << static_cast<TTestHttpParser*>(this)->GetState() << ", CheckDocPart(" << s.Quote() << ")\n"; - Body_ += s; - } - }; + // other functions are not really called by THttpParser + void CheckDocPart(const void* buf, size_t len, THttpHeader* /* header */) { + TString s(static_cast<const char*>(buf), len); + Cout << "State = " << static_cast<TTestHttpParser*>(this)->GetState() << ", CheckDocPart(" << s.Quote() << ")\n"; + Body_ += s; + } + }; -} +} Y_UNIT_TEST_SUITE(TestHttpParser) { Y_UNIT_TEST(TestTrivialRequest) { @@ -73,9 +73,9 @@ Y_UNIT_TEST_SUITE(TestHttpParser) { UNIT_ASSERT_EQUAL(parser.GetState(), parser.hp_eof); UNIT_ASSERT_EQUAL(parser.Body(), "OK"); UNIT_ASSERT_EQUAL(hdr.header_size, strlen( - "HTTP/1.1 200 Ok\r\n" - "Content-Length: 2\r\n" - "\r\n")); + "HTTP/1.1 200 Ok\r\n" + "Content-Length: 2\r\n" + "\r\n")); UNIT_ASSERT_EQUAL(hdr.entity_size, strlen("OK")); } @@ -98,36 +98,36 @@ Y_UNIT_TEST_SUITE(TestHttpParser) { UNIT_ASSERT_EQUAL(parser.GetState(), parser.hp_eof); UNIT_ASSERT_EQUAL(parser.Body(), "OkAllRight"); UNIT_ASSERT_EQUAL(hdr.header_size, strlen( - "HTTP/1.1 200 OK\r\n" - "Transfer-Encoding: chunked\r\n" - "\r\n")); + "HTTP/1.1 200 OK\r\n" + "Transfer-Encoding: chunked\r\n" + "\r\n")); const int off_by_one_err = -1; // XXX: it really looks so UNIT_ASSERT_EQUAL(hdr.entity_size + off_by_one_err, strlen( - "2\r\n" - "Ok\r\n" - "8\r\n" - "AllRight\r\n" - "0\r\n" - "\r\n")); + "2\r\n" + "Ok\r\n" + "8\r\n" + "AllRight\r\n" + "0\r\n" + "\r\n")); } static const TString PipelineClenBlob_{ - "HTTP/1.1 200 Ok\r\n" - "Content-Length: 4\r\n" - "\r\n" - "OK\r\n" - "HTTP/1.1 200 Zz\r\n" - "Content-Length: 4\r\n" - "\r\n" - "ZZ\r\n"}; - - void AssertPipelineClen(TTestHttpParser & parser, const THttpHeader& hdr) { + "HTTP/1.1 200 Ok\r\n" + "Content-Length: 4\r\n" + "\r\n" + "OK\r\n" + "HTTP/1.1 200 Zz\r\n" + "Content-Length: 4\r\n" + "\r\n" + "ZZ\r\n"}; + + void AssertPipelineClen(TTestHttpParser & parser, const THttpHeader& hdr) { UNIT_ASSERT_EQUAL(parser.GetState(), parser.hp_eof); UNIT_ASSERT_EQUAL(4, hdr.content_length); UNIT_ASSERT_EQUAL(hdr.header_size, strlen( - "HTTP/1.1 200 Ok\r\n" - "Content-Length: 4\r\n" - "\r\n")); + "HTTP/1.1 200 Ok\r\n" + "Content-Length: 4\r\n" + "\r\n")); } Y_UNIT_TEST(TestPipelineClenByteByByte) { @@ -154,55 +154,55 @@ Y_UNIT_TEST_SUITE(TestHttpParser) { parser.Parse((void*)blob.data(), blob.size()); AssertPipelineClen(parser, hdr); UNIT_ASSERT_EQUAL(parser.Body(), - "OK\r\n" - "HTTP/1.1 200 Zz\r\n" - "Content-Length: 4\r\n" - "\r\n" - "ZZ\r\n"); + "OK\r\n" + "HTTP/1.1 200 Zz\r\n" + "Content-Length: 4\r\n" + "\r\n" + "ZZ\r\n"); UNIT_ASSERT_EQUAL(hdr.entity_size, strlen( - "OK\r\n" - "HTTP/1.1 200 Zz\r\n" - "Content-Length: 4\r\n" - "\r\n" - "ZZ\r\n")); + "OK\r\n" + "HTTP/1.1 200 Zz\r\n" + "Content-Length: 4\r\n" + "\r\n" + "ZZ\r\n")); } static const TString PipelineChunkedBlob_{ - "HTTP/1.1 200 OK\r\n" - "Transfer-Encoding: chunked\r\n" - "\r\n" - "2\r\n" - "Ok\r\n" - "8\r\n" - "AllRight\r\n" - "0\r\n" - "\r\n" - "HTTP/1.1 200 OK\r\n" - "Transfer-Encoding: chunked\r\n" - "\r\n" - "2\r\n" - "Yo\r\n" - "8\r\n" - "uWin!Iam\r\n" - "0\r\n" - "\r\n"}; - - void AssertPipelineChunked(TTestHttpParser & parser, const THttpHeader& hdr) { + "HTTP/1.1 200 OK\r\n" + "Transfer-Encoding: chunked\r\n" + "\r\n" + "2\r\n" + "Ok\r\n" + "8\r\n" + "AllRight\r\n" + "0\r\n" + "\r\n" + "HTTP/1.1 200 OK\r\n" + "Transfer-Encoding: chunked\r\n" + "\r\n" + "2\r\n" + "Yo\r\n" + "8\r\n" + "uWin!Iam\r\n" + "0\r\n" + "\r\n"}; + + void AssertPipelineChunked(TTestHttpParser & parser, const THttpHeader& hdr) { UNIT_ASSERT_EQUAL(parser.GetState(), parser.hp_eof); UNIT_ASSERT_EQUAL(parser.Body(), "OkAllRight"); UNIT_ASSERT_EQUAL(-1, hdr.content_length); UNIT_ASSERT_EQUAL(hdr.header_size, strlen( - "HTTP/1.1 200 OK\r\n" - "Transfer-Encoding: chunked\r\n" - "\r\n")); + "HTTP/1.1 200 OK\r\n" + "Transfer-Encoding: chunked\r\n" + "\r\n")); const int off_by_one_err = -1; UNIT_ASSERT_EQUAL(hdr.entity_size + off_by_one_err, strlen( - "2\r\n" - "Ok\r\n" - "8\r\n" - "AllRight\r\n" - "0\r\n" - "\r\n")); + "2\r\n" + "Ok\r\n" + "8\r\n" + "AllRight\r\n" + "0\r\n" + "\r\n")); } Y_UNIT_TEST(TestPipelineChunkedByteByByte) { diff --git a/library/cpp/http/fetch/httpzreader.h b/library/cpp/http/fetch/httpzreader.h index a8df608a9f..68eb00853d 100644 --- a/library/cpp/http/fetch/httpzreader.h +++ b/library/cpp/http/fetch/httpzreader.h @@ -1,26 +1,26 @@ #pragma once -#include "httpheader.h" -#include "httpparser.h" -#include "exthttpcodes.h" +#include "httpheader.h" +#include "httpparser.h" +#include "exthttpcodes.h" #include <util/system/defaults.h> #include <util/generic/yexception.h> #include <contrib/libs/zlib/zlib.h> -#include <errno.h> - +#include <errno.h> + #ifndef ENOTSUP -#define ENOTSUP 45 +#define ENOTSUP 45 #endif template <class Reader> class TCompressedHttpReader: public THttpReader<Reader> { typedef THttpReader<Reader> TBase; - + public: - using TBase::AssumeConnectionClosed; + using TBase::AssumeConnectionClosed; using TBase::Header; using TBase::ParseGeneric; using TBase::State; @@ -78,7 +78,7 @@ public: return ret; } - long Read(void*& buf) { + long Read(void*& buf) { if (!CompressedInput) { long res = TBase::Read(buf); if (res > 0) { @@ -93,7 +93,7 @@ public: while (true) { if (Stream.avail_in == 0) { - void* tmpin = Stream.next_in; + void* tmpin = Stream.next_in; long res = TBase::Read(tmpin); Stream.next_in = (Bytef*)tmpin; if (res <= 0) @@ -121,10 +121,10 @@ public: ZErr = E2BIG; return -1; } - if (!IgnoreTrailingGarbage && BufSize == Stream.avail_out && Stream.avail_in > 0) { + if (!IgnoreTrailingGarbage && BufSize == Stream.avail_out && Stream.avail_in > 0) { Header->error = EXT_HTTP_GZIPERROR; ZErr = EFAULT; - Stream.msg = (char*)"trailing garbage"; + Stream.msg = (char*)"trailing garbage"; return -1; } return long(BufSize - Stream.avail_out); @@ -148,7 +148,7 @@ public: return -1; } - const char* ZMsg() const { + const char* ZMsg() const { return Stream.msg; } @@ -173,7 +173,7 @@ protected: return 0; case HTTP_COMPRESSION_GZIP: CompressedInput = true; - winsize += 16; // 16 indicates gzip, see zlib.h + winsize += 16; // 16 indicates gzip, see zlib.h break; case HTTP_COMPRESSION_DEFLATE: CompressedInput = true; @@ -240,21 +240,21 @@ protected: bool IgnoreTrailingGarbage; }; -class zlib_exception: public yexception { +class zlib_exception: public yexception { }; template <class Reader> class SCompressedHttpReader: public TCompressedHttpReader<Reader> { typedef TCompressedHttpReader<Reader> TBase; - + public: using TBase::ZError; using TBase::ZMsg; SCompressedHttpReader() - : TBase() - { - } + : TBase() + { + } int Init( THttpHeader* H, @@ -268,7 +268,7 @@ public: return (int)HandleRetValue((long)ret); } - long Read(void*& buf) { + long Read(void*& buf) { long ret = TBase::Read(buf); return HandleRetValue(ret); } @@ -281,7 +281,7 @@ protected: case ENOMEM: ythrow yexception() << "SCompressedHttpReader: not enough memory"; case EINVAL: - ythrow yexception() << "SCompressedHttpReader: zlib error: " << ZMsg(); + ythrow yexception() << "SCompressedHttpReader: zlib error: " << ZMsg(); case ENOTSUP: ythrow yexception() << "SCompressedHttpReader: unsupported compression method"; case EFAULT: diff --git a/library/cpp/http/fetch/library-htfetch_ut_hreflang_in.h b/library/cpp/http/fetch/library-htfetch_ut_hreflang_in.h index d01a5911e7..0df89bdc79 100644 --- a/library/cpp/http/fetch/library-htfetch_ut_hreflang_in.h +++ b/library/cpp/http/fetch/library-htfetch_ut_hreflang_in.h @@ -1,155 +1,155 @@ #pragma once char hreflang_ut_in[] = "HTTP/1.1 200 OK\n" - "Date: Thu, 15 Nov 2012 22:38:28 GMT\n" - "Server: Apache/2\n" - "X-Powered-By: PHP/5.2.17\n" - "Set-Cookie: PHPSESSID=6d69474d1cc019d7d82714c9472bc6d6; path=/\n" - "Expires: Thu, 19 Nov 1981 08:52:00 GMT\n" - "Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0\n" - "Pragma: no-cache\n" - "Link: <http://www.forexticket.cn.com/zh/currency/converter-EEK-XAG>; rel='alternate'; hreflang='zh-CN'\n" - "Link: <http://www.forexticket.tw/zh/currency/converter-EEK-XAG>; rel='alternate'; hreflang='zh-TW'\n" - "Link: <http://www.forexticket.hk/zh/currency/converter-EEK-XAG>; rel='alternate'; hreflang='zh-HK'\n" - "Link: <http://www.forexticket.sg/zh/currency/converter-EEK-XAG>; rel='alternate'; hreflang='zh-SG'\n" - "Link: <http://www.forexticket.in/hi/currency/converter-EEK-XAG>; rel='alternate'; hreflang='hi-IN'\n" - "Link: <http://www.forexticket.com.fj/hi/currency/converter-EEK-XAG>; rel='alternate'; hreflang='hi-FJ'\n" - "Link: <http://www.forexticket.in/en/currency/converter-EEK-XAG>; rel='alternate'; hreflang='en-IN'\n" - "Link: <http://www.forexticket.us/en/currency/converter-EEK-XAG>; rel='alternate'; hreflang='en-US'\n" - "Link: <http://www.forexticket.com.pk/en/currency/converter-EEK-XAG>; rel='alternate'; hreflang='en-PK'\n" - "Link: <http://www.forexticket-bd.com/en/currency/converter-EEK-XAG>; rel='alternate'; hreflang='en-BD'\n" - "Link: <http://www.forexticket-ng.com/en/currency/converter-EEK-XAG>; rel='alternate'; hreflang='en-NG'\n" - "Link: <http://www.forexticket.co.uk/en/currency/converter-EEK-XAG>; rel='alternate'; hreflang='en-GB'\n" - "Link: <http://www.forexticket.co.za/en/currency/converter-EEK-XAG>; rel='alternate'; hreflang='en-ZA'\n" - "Link: <http://www.forexticket.co.ke/en/currency/converter-EEK-XAG>; rel='alternate'; hreflang='en-KE'\n" - "Link: <http://www.forexticket.com/en/currency/converter-EEK-XAG>; rel='alternate'; hreflang='en-CA'\n" - "Link: <http://www.forexticket-gh.com/en/currency/converter-EEK-XAG>; rel='alternate'; hreflang='en-GH'\n" - "Link: <http://www.forexticket.biz/en/currency/converter-EEK-XAG>; rel='alternate'; hreflang='en-AU'\n" - "Link: <http://www.forexticket.cm/en/currency/converter-EEK-XAG>; rel='alternate'; hreflang='en-CM'\n" - "Link: <http://www.forexticket-kh.com/en/currency/converter-EEK-XAG>; rel='alternate'; hreflang='en-KH'\n" - "Link: <http://www.forexticket.hk/en/currency/converter-EEK-XAG>; rel='alternate'; hreflang='en-HK'\n" - "Link: <http://www.forexticket.la/en/currency/converter-EEK-XAG>; rel='alternate'; hreflang='en-LA'\n" - "Link: <http://www.forexticket.sg/en/currency/converter-EEK-XAG>; rel='alternate'; hreflang='en-SG'\n" - "Link: <http://www.forexticket.co.nz/en/currency/converter-EEK-XAG>; rel='alternate'; hreflang='en-NZ'\n" - "Link: <http://www.forexticket.com.pr/en/currency/converter-EEK-XAG>; rel='alternate'; hreflang='en-PR'\n" - "Link: <http://www.forexticket.com.fj/en/currency/converter-EEK-XAG>; rel='alternate'; hreflang='en-FJ'\n" - "Link: <http://www.forexticket.us/es/cambio/divisas-EEK-XAG>; rel='alternate'; hreflang='es-US'\n" - "Link: <http://www.forexticket.mx/es/cambio/divisas-EEK-XAG>; rel='alternate'; hreflang='es-MX'\n" - "Link: <http://www.forexticket.co/es/cambio/divisas-EEK-XAG>; rel='alternate'; hreflang='es-CO'\n" - "Link: <http://www.forexticket.com.ar/es/cambio/divisas-EEK-XAG>; rel='alternate'; hreflang='es-AR'\n" - "Link: <http://www.forexticket-pe.com/es/cambio/divisas-EEK-XAG>; rel='alternate'; hreflang='es-PE'\n" - "Link: <http://www.forexticket.co.ve/es/cambio/divisas-EEK-XAG>; rel='alternate'; hreflang='es-VE'\n" - "Link: <http://www.forexticket.cl/es/cambio/divisas-EEK-XAG>; rel='alternate'; hreflang='es-CL'\n" - "Link: <http://www.forexticket.ec/es/cambio/divisas-EEK-XAG>; rel='alternate'; hreflang='es-EC'\n" - "Link: <http://www.forexticket.com.gt/es/cambio/divisas-EEK-XAG>; rel='alternate'; hreflang='es-GT'\n" - "Link: <http://www.forexticket.bo/es/cambio/divisas-EEK-XAG>; rel='alternate'; hreflang='es-BO'\n" - "Link: <http://www.forexticket.hn/es/cambio/divisas-EEK-XAG>; rel='alternate'; hreflang='es-HN'\n" - "Link: <http://www.forexticket.com.py/es/cambio/divisas-EEK-XAG>; rel='alternate'; hreflang='es-PY'\n" - "Link: <http://www.forexticket.es/es/cambio/divisas-EEK-XAG>; rel='alternate'; hreflang='es-ES'\n" - "Link: <http://www.forexticket.com.sv/es/cambio/divisas-EEK-XAG>; rel='alternate'; hreflang='es-SV'\n" - "Link: <http://www.forexticket.com.ni/es/cambio/divisas-EEK-XAG>; rel='alternate'; hreflang='es-NI'\n" - "Link: <http://www.forexticket.co.cr/es/cambio/divisas-EEK-XAG>; rel='alternate'; hreflang='es-CR'\n" - "Link: <http://www.forexticket.com.pr/es/cambio/divisas-EEK-XAG>; rel='alternate'; hreflang='es-PR'\n" - "Link: <http://www.forexticket.com.uy/es/cambio/divisas-EEK-XAG>; rel='alternate'; hreflang='es-UY'\n" - "Link: <http://www.forexticket.com.pa/es/cambio/divisas-EEK-XAG>; rel='alternate'; hreflang='es-PA'\n" - "Link: <http://www.forexticket.asia.com/id/currency/converter-EEK-XAG>; rel='alternate'; hreflang='id-ID'\n" - "Link: <http://www.forexticket.com.br/pt/moeda/conversor-EEK-XAG>; rel='alternate'; hreflang='pt-BR'\n" - "Link: <http://www.forexticket-mz.com/pt/moeda/conversor-EEK-XAG>; rel='alternate'; hreflang='pt-MZ'\n" - "Link: <http://www.forexticket.com.pt/pt/moeda/conversor-EEK-XAG>; rel='alternate'; hreflang='pt-PT'\n" - "Link: <http://www.forexticket.tl/pt/moeda/conversor-EEK-XAG>; rel='alternate'; hreflang='pt-TL'\n" - "Link: <http://www.forexticket.ru/ru/currency/converter-EEK-XAG>; rel='alternate'; hreflang='ru-RU'\n" - "Link: <http://www.forexticket-kz.com/ru/currency/converter-EEK-XAG>; rel='alternate'; hreflang='ru-KZ'\n" - "Link: <http://www.forexticket-tj.com/ru/currency/converter-EEK-XAG>; rel='alternate'; hreflang='ru-TJ'\n" - "Link: <http://www.forexticket-kg.com/ru/currency/converter-EEK-XAG>; rel='alternate'; hreflang='ru-KG'\n" - "Link: <http://www.forexticket-ge.com/ru/currency/converter-EEK-XAG>; rel='alternate'; hreflang='ru-GE'\n" - "Link: <http://www.forexticket.mn/ru/currency/converter-EEK-XAG>; rel='alternate'; hreflang='ru-MN'\n" - "Link: <http://www.forexticket.jp/ja/currency/converter-EEK-XAG>; rel='alternate'; hreflang='ja-JP'\n" - "Link: <http://www.forexticket-ph.com/tl/currency/converter-EEK-XAG>; rel='alternate'; hreflang='tl-PH'\n" - "Link: <http://www.forexticket.vn/vi/currency/converter-EEK-XAG>; rel='alternate'; hreflang='vi-VN'\n" - "Link: <http://www.forexticket.de/de/waehrungsumrechner/devisen-EEK-XAG>; rel='alternate'; hreflang='de-DE'\n" - "Link: <http://www.forexticket.be/de/waehrungsumrechner/devisen-EEK-XAG>; rel='alternate'; hreflang='de-BE'\n" - "Link: <http://www.forexticket.at/de/waehrungsumrechner/devisen-EEK-XAG>; rel='alternate'; hreflang='de-AT'\n" - "Link: <http://www.forexticket.ch/de/waehrungsumrechner/devisen-EEK-XAG>; rel='alternate'; hreflang='de-CH'\n" - "Link: <http://www.forexticket.lu/de/waehrungsumrechner/devisen-EEK-XAG>; rel='alternate'; hreflang='de-LU'\n" - "Link: <http://www.forexticket.li/de/waehrungsumrechner/devisen-EEK-XAG>; rel='alternate'; hreflang='de-LI'\n" - "Link: <http://www.forexticket.de/de/waehrungsumrechner/devisen-EEK-XAG>; rel='canonical'\n" - "Link: <http://www.forexticket-eg.com/ar/currency/converter-EEK-XAG>; rel='alternate'; hreflang='ar-EG'\n" - "Link: <http://www.forexticket-dz.com/ar/currency/converter-EEK-XAG>; rel='alternate'; hreflang='ar-DZ'\n" - "Link: <http://www.forexticket-ma.com/ar/currency/converter-EEK-XAG>; rel='alternate'; hreflang='ar-MA'\n" - "Link: <http://www.forexticket-iq.com/ar/currency/converter-EEK-XAG>; rel='alternate'; hreflang='ar-IQ'\n" - "Link: <http://www.forexticket-sa.com/ar/currency/converter-EEK-XAG>; rel='alternate'; hreflang='ar-SA'\n" - "Link: <http://www.forexticket-sy.com/ar/currency/converter-EEK-XAG>; rel='alternate'; hreflang='ar-SY'\n" - "Link: <http://www.forexticket-tn.com/ar/currency/converter-EEK-XAG>; rel='alternate'; hreflang='ar-TN'\n" - "Link: <http://www.forexticket-td.com/ar/currency/converter-EEK-XAG>; rel='alternate'; hreflang='ar-TD'\n" - "Link: <http://www.forexticket-so.com/ar/currency/converter-EEK-XAG>; rel='alternate'; hreflang='ar-SO'\n" - "Link: <http://www.forexticket.co.il/ar/currency/converter-EEK-XAG>; rel='alternate'; hreflang='ar-IL'\n" - "Link: <http://www.forexticket-jo.com/ar/currency/converter-EEK-XAG>; rel='alternate'; hreflang='ar-JO'\n" - "Link: <http://www.forexticket.ae/ar/currency/converter-EEK-XAG>; rel='alternate'; hreflang='ar-AE'\n" - "Link: <http://www.forexticket-lb.com/ar/currency/converter-EEK-XAG>; rel='alternate'; hreflang='ar-LB'\n" - "Link: <http://www.forexticket-om.com/ar/currency/converter-EEK-XAG>; rel='alternate'; hreflang='ar-OM'\n" - "Link: <http://www.forexticket-kw.com/ar/currency/converter-EEK-XAG>; rel='alternate'; hreflang='ar-KW'\n" - "Link: <http://www.forexticket-tr.com/tr/currency/converter-EEK-XAG>; rel='alternate'; hreflang='tr-TR'\n" - "Link: <http://www.forexticket-bg.com/tr/currency/converter-EEK-XAG>; rel='alternate'; hreflang='tr-BG'\n" - "Link: <http://www.forexticket-cy.com/tr/currency/converter-EEK-XAG>; rel='alternate'; hreflang='tr-CY'\n" - "Link: <http://www.forexticket.ir/fa/currency/converter-EEK-XAG>; rel='alternate'; hreflang='fa-IR'\n" - "Link: <http://www.forexticket.af/fa/currency/converter-EEK-XAG>; rel='alternate'; hreflang='fa-AF'\n" - "Link: <http://www.forexticket.cd/fr/conversion/monnaie-EEK-XAG>; rel='alternate'; hreflang='fr-CD'\n" - "Link: <http://www.forexticket.fr/fr/conversion/monnaie-EEK-XAG>; rel='alternate'; hreflang='fr-FR'\n" - "Link: <http://www.forexticket.com/fr/conversion/monnaie-EEK-XAG>; rel='alternate'; hreflang='fr-CA'\n" - "Link: <http://www.forexticket.mg/fr/conversion/monnaie-EEK-XAG>; rel='alternate'; hreflang='fr-MG'\n" - "Link: <http://www.forexticket.cm/fr/conversion/monnaie-EEK-XAG>; rel='alternate'; hreflang='fr-CM'\n" - "Link: <http://www.forexticket-kh.com/fr/conversion/monnaie-EEK-XAG>; rel='alternate'; hreflang='fr-KH'\n" - "Link: <http://www.forexticket-ml.com/fr/conversion/monnaie-EEK-XAG>; rel='alternate'; hreflang='fr-ML'\n" - "Link: <http://www.forexticket-sn.com/fr/conversion/monnaie-EEK-XAG>; rel='alternate'; hreflang='fr-SN'\n" - "Link: <http://www.forexticket-tn.com/fr/conversion/monnaie-EEK-XAG>; rel='alternate'; hreflang='fr-TN'\n" - "Link: <http://www.forexticket-td.com/fr/conversion/monnaie-EEK-XAG>; rel='alternate'; hreflang='fr-TD'\n" - "Link: <http://www.forexticket.be/fr/conversion/monnaie-EEK-XAG>; rel='alternate'; hreflang='fr-BE'\n" - "Link: <http://www.forexticket-gn.com/fr/conversion/monnaie-EEK-XAG>; rel='alternate'; hreflang='fr-GN'\n" - "Link: <http://www.forexticket.ht/fr/conversion/monnaie-EEK-XAG>; rel='alternate'; hreflang='fr-HT'\n" - "Link: <http://www.forexticket.ch/fr/conversion/monnaie-EEK-XAG>; rel='alternate'; hreflang='fr-CH'\n" - "Link: <http://www.forexticket.la/fr/conversion/monnaie-EEK-XAG>; rel='alternate'; hreflang='fr-LA'\n" - "Link: <http://www.forexticket.lu/fr/conversion/monnaie-EEK-XAG>; rel='alternate'; hreflang='fr-LU'\n" - "Link: <http://www.forexticket-th.com/th/currency/converter-EEK-XAG>; rel='alternate'; hreflang='th-TH'\n" - "Link: <http://www.forexticket.co.uk/cy/currency/converter-EEK-XAG>; rel='alternate'; hreflang='cy-GB'\n" - "Link: <http://www.forexticket.co.uk/ga/currency/converter-EEK-XAG>; rel='alternate'; hreflang='ga-GB'\n" - "Link: <http://www.forexticket.it/it/convertitore/valuta-EEK-XAG>; rel='alternate'; hreflang='it-IT'\n" - "Link: <http://www.forexticket.ch/it/convertitore/valuta-EEK-XAG>; rel='alternate'; hreflang='it-CH'\n" - "Link: <http://www.forexticket.co.za/af/currency/converter-EEK-XAG>; rel='alternate'; hreflang='af-ZA'\n" - "Link: <http://www.forexticket.kr/ko/currency/converter-EEK-XAG>; rel='alternate'; hreflang='ko-KR'\n" - "Link: <http://www.forexticket-ua.com/uk/currency/converter-EEK-XAG>; rel='alternate'; hreflang='uk-UA'\n" - "Link: <http://www.forexticket-tz.com/sw/currency/converter-EEK-XAG>; rel='alternate'; hreflang='sw-TZ'\n" - "Link: <http://www.forexticket.co.ke/sw/currency/converter-EEK-XAG>; rel='alternate'; hreflang='sw-KE'\n" - "Link: <http://www.forexticket.pl/pl/currency/converter-EEK-XAG>; rel='alternate'; hreflang='pl-PL'\n" - "Link: <http://www.forexticket.com.my/ms/currency/converter-EEK-XAG>; rel='alternate'; hreflang='ms-MY'\n" - "Link: <http://www.forexticket.sg/ms/currency/converter-EEK-XAG>; rel='alternate'; hreflang='ms-SG'\n" - "Link: <http://www.forexticket.ro/ro/currency/converter-EEK-XAG>; rel='alternate'; hreflang='ro-RO'\n" - "Link: <http://www.forexticket.nl/nl/currency/converter-EEK-XAG>; rel='alternate'; hreflang='nl-NL'\n" - "Link: <http://www.forexticket.be/nl/currency/converter-EEK-XAG>; rel='alternate'; hreflang='nl-BE'\n" - "Link: <http://www.forexticket.gr/el/currency/converter-EEK-XAG>; rel='alternate'; hreflang='el-GR'\n" - "Link: <http://www.forexticket-al.com/el/currency/converter-EEK-XAG>; rel='alternate'; hreflang='el-AL'\n" - "Link: <http://www.forexticket-cy.com/el/currency/converter-EEK-XAG>; rel='alternate'; hreflang='el-CY'\n" - "Link: <http://www.forexticket.cz/cs/currency/converter-EEK-XAG>; rel='alternate'; hreflang='cs-CZ'\n" - "Link: <http://www.forexticket.hu/hu/currency/converter-EEK-XAG>; rel='alternate'; hreflang='hu-HU'\n" - "Link: <http://www.forexticket.se/sv/currency/converter-EEK-XAG>; rel='alternate'; hreflang='sv-SE'\n" - "Link: <http://www.forexticket.eu/sv/currency/converter-EEK-XAG>; rel='alternate'; hreflang='sv-FI'\n" - "Link: <http://www.forexticket.co.il/iw/currency/converter-EEK-XAG>; rel='alternate'; hreflang='iw-IL'\n" - "Link: <http://www.forexticket.co.il/yi/currency/converter-EEK-XAG>; rel='alternate'; hreflang='yi-IL'\n" - "Link: <http://www.forexticket-bg.com/bg/currency/converter-EEK-XAG>; rel='alternate'; hreflang='bg-BG'\n" - "Link: <http://www.forexticket.es/ca/currency/converter-EEK-XAG>; rel='alternate'; hreflang='ca-ES'\n" - "Link: <http://www.forexticket.es/gl/currency/converter-EEK-XAG>; rel='alternate'; hreflang='gl-ES'\n" - "Link: <http://www.forexticket.dk/da/currency/converter-EEK-XAG>; rel='alternate'; hreflang='da-DK'\n" - "Link: <http://www.forexticket.eu/fi/currency/converter-EEK-XAG>; rel='alternate'; hreflang='fi-FI'\n" - "Link: <http://www.forexticket-hr.com/hr/currency/converter-EEK-XAG>; rel='alternate'; hreflang='hr-HR'\n" - "Link: <http://www.forexticket-hr.com/sr/currency/converter-EEK-XAG>; rel='alternate'; hreflang='sr-HR'\n" - "Link: <http://www.forexticket.me/sr/currency/converter-EEK-XAG>; rel='alternate'; hreflang='sr-ME'\n" - "Link: <http://www.forexticket.lt/lt/currency/converter-EEK-XAG>; rel='alternate'; hreflang='lt-LT'\n" - "Link: <http://www.forexticket-al.com/sq/currency/converter-EEK-XAG>; rel='alternate'; hreflang='sq-AL'\n" - "Link: <http://www.forexticket.lv/lv/currency/converter-EEK-XAG>; rel='alternate'; hreflang='lv-LV'\n" - "Link: <http://www.forexticket.co.ee/et/currency/converter-EEK-XAG>; rel='alternate'; hreflang='et-EE'\n" - "Vary: Accept-Encoding,User-Agent\n" - "Content-Encoding: gzip\n" - "Keep-Alive: timeout=1, max=100\n" - "Connection: Keep-Alive\n" - "Transfer-Encoding: chunked\n" - "Content-Type: text/html\n" - "\n"; + "Date: Thu, 15 Nov 2012 22:38:28 GMT\n" + "Server: Apache/2\n" + "X-Powered-By: PHP/5.2.17\n" + "Set-Cookie: PHPSESSID=6d69474d1cc019d7d82714c9472bc6d6; path=/\n" + "Expires: Thu, 19 Nov 1981 08:52:00 GMT\n" + "Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0\n" + "Pragma: no-cache\n" + "Link: <http://www.forexticket.cn.com/zh/currency/converter-EEK-XAG>; rel='alternate'; hreflang='zh-CN'\n" + "Link: <http://www.forexticket.tw/zh/currency/converter-EEK-XAG>; rel='alternate'; hreflang='zh-TW'\n" + "Link: <http://www.forexticket.hk/zh/currency/converter-EEK-XAG>; rel='alternate'; hreflang='zh-HK'\n" + "Link: <http://www.forexticket.sg/zh/currency/converter-EEK-XAG>; rel='alternate'; hreflang='zh-SG'\n" + "Link: <http://www.forexticket.in/hi/currency/converter-EEK-XAG>; rel='alternate'; hreflang='hi-IN'\n" + "Link: <http://www.forexticket.com.fj/hi/currency/converter-EEK-XAG>; rel='alternate'; hreflang='hi-FJ'\n" + "Link: <http://www.forexticket.in/en/currency/converter-EEK-XAG>; rel='alternate'; hreflang='en-IN'\n" + "Link: <http://www.forexticket.us/en/currency/converter-EEK-XAG>; rel='alternate'; hreflang='en-US'\n" + "Link: <http://www.forexticket.com.pk/en/currency/converter-EEK-XAG>; rel='alternate'; hreflang='en-PK'\n" + "Link: <http://www.forexticket-bd.com/en/currency/converter-EEK-XAG>; rel='alternate'; hreflang='en-BD'\n" + "Link: <http://www.forexticket-ng.com/en/currency/converter-EEK-XAG>; rel='alternate'; hreflang='en-NG'\n" + "Link: <http://www.forexticket.co.uk/en/currency/converter-EEK-XAG>; rel='alternate'; hreflang='en-GB'\n" + "Link: <http://www.forexticket.co.za/en/currency/converter-EEK-XAG>; rel='alternate'; hreflang='en-ZA'\n" + "Link: <http://www.forexticket.co.ke/en/currency/converter-EEK-XAG>; rel='alternate'; hreflang='en-KE'\n" + "Link: <http://www.forexticket.com/en/currency/converter-EEK-XAG>; rel='alternate'; hreflang='en-CA'\n" + "Link: <http://www.forexticket-gh.com/en/currency/converter-EEK-XAG>; rel='alternate'; hreflang='en-GH'\n" + "Link: <http://www.forexticket.biz/en/currency/converter-EEK-XAG>; rel='alternate'; hreflang='en-AU'\n" + "Link: <http://www.forexticket.cm/en/currency/converter-EEK-XAG>; rel='alternate'; hreflang='en-CM'\n" + "Link: <http://www.forexticket-kh.com/en/currency/converter-EEK-XAG>; rel='alternate'; hreflang='en-KH'\n" + "Link: <http://www.forexticket.hk/en/currency/converter-EEK-XAG>; rel='alternate'; hreflang='en-HK'\n" + "Link: <http://www.forexticket.la/en/currency/converter-EEK-XAG>; rel='alternate'; hreflang='en-LA'\n" + "Link: <http://www.forexticket.sg/en/currency/converter-EEK-XAG>; rel='alternate'; hreflang='en-SG'\n" + "Link: <http://www.forexticket.co.nz/en/currency/converter-EEK-XAG>; rel='alternate'; hreflang='en-NZ'\n" + "Link: <http://www.forexticket.com.pr/en/currency/converter-EEK-XAG>; rel='alternate'; hreflang='en-PR'\n" + "Link: <http://www.forexticket.com.fj/en/currency/converter-EEK-XAG>; rel='alternate'; hreflang='en-FJ'\n" + "Link: <http://www.forexticket.us/es/cambio/divisas-EEK-XAG>; rel='alternate'; hreflang='es-US'\n" + "Link: <http://www.forexticket.mx/es/cambio/divisas-EEK-XAG>; rel='alternate'; hreflang='es-MX'\n" + "Link: <http://www.forexticket.co/es/cambio/divisas-EEK-XAG>; rel='alternate'; hreflang='es-CO'\n" + "Link: <http://www.forexticket.com.ar/es/cambio/divisas-EEK-XAG>; rel='alternate'; hreflang='es-AR'\n" + "Link: <http://www.forexticket-pe.com/es/cambio/divisas-EEK-XAG>; rel='alternate'; hreflang='es-PE'\n" + "Link: <http://www.forexticket.co.ve/es/cambio/divisas-EEK-XAG>; rel='alternate'; hreflang='es-VE'\n" + "Link: <http://www.forexticket.cl/es/cambio/divisas-EEK-XAG>; rel='alternate'; hreflang='es-CL'\n" + "Link: <http://www.forexticket.ec/es/cambio/divisas-EEK-XAG>; rel='alternate'; hreflang='es-EC'\n" + "Link: <http://www.forexticket.com.gt/es/cambio/divisas-EEK-XAG>; rel='alternate'; hreflang='es-GT'\n" + "Link: <http://www.forexticket.bo/es/cambio/divisas-EEK-XAG>; rel='alternate'; hreflang='es-BO'\n" + "Link: <http://www.forexticket.hn/es/cambio/divisas-EEK-XAG>; rel='alternate'; hreflang='es-HN'\n" + "Link: <http://www.forexticket.com.py/es/cambio/divisas-EEK-XAG>; rel='alternate'; hreflang='es-PY'\n" + "Link: <http://www.forexticket.es/es/cambio/divisas-EEK-XAG>; rel='alternate'; hreflang='es-ES'\n" + "Link: <http://www.forexticket.com.sv/es/cambio/divisas-EEK-XAG>; rel='alternate'; hreflang='es-SV'\n" + "Link: <http://www.forexticket.com.ni/es/cambio/divisas-EEK-XAG>; rel='alternate'; hreflang='es-NI'\n" + "Link: <http://www.forexticket.co.cr/es/cambio/divisas-EEK-XAG>; rel='alternate'; hreflang='es-CR'\n" + "Link: <http://www.forexticket.com.pr/es/cambio/divisas-EEK-XAG>; rel='alternate'; hreflang='es-PR'\n" + "Link: <http://www.forexticket.com.uy/es/cambio/divisas-EEK-XAG>; rel='alternate'; hreflang='es-UY'\n" + "Link: <http://www.forexticket.com.pa/es/cambio/divisas-EEK-XAG>; rel='alternate'; hreflang='es-PA'\n" + "Link: <http://www.forexticket.asia.com/id/currency/converter-EEK-XAG>; rel='alternate'; hreflang='id-ID'\n" + "Link: <http://www.forexticket.com.br/pt/moeda/conversor-EEK-XAG>; rel='alternate'; hreflang='pt-BR'\n" + "Link: <http://www.forexticket-mz.com/pt/moeda/conversor-EEK-XAG>; rel='alternate'; hreflang='pt-MZ'\n" + "Link: <http://www.forexticket.com.pt/pt/moeda/conversor-EEK-XAG>; rel='alternate'; hreflang='pt-PT'\n" + "Link: <http://www.forexticket.tl/pt/moeda/conversor-EEK-XAG>; rel='alternate'; hreflang='pt-TL'\n" + "Link: <http://www.forexticket.ru/ru/currency/converter-EEK-XAG>; rel='alternate'; hreflang='ru-RU'\n" + "Link: <http://www.forexticket-kz.com/ru/currency/converter-EEK-XAG>; rel='alternate'; hreflang='ru-KZ'\n" + "Link: <http://www.forexticket-tj.com/ru/currency/converter-EEK-XAG>; rel='alternate'; hreflang='ru-TJ'\n" + "Link: <http://www.forexticket-kg.com/ru/currency/converter-EEK-XAG>; rel='alternate'; hreflang='ru-KG'\n" + "Link: <http://www.forexticket-ge.com/ru/currency/converter-EEK-XAG>; rel='alternate'; hreflang='ru-GE'\n" + "Link: <http://www.forexticket.mn/ru/currency/converter-EEK-XAG>; rel='alternate'; hreflang='ru-MN'\n" + "Link: <http://www.forexticket.jp/ja/currency/converter-EEK-XAG>; rel='alternate'; hreflang='ja-JP'\n" + "Link: <http://www.forexticket-ph.com/tl/currency/converter-EEK-XAG>; rel='alternate'; hreflang='tl-PH'\n" + "Link: <http://www.forexticket.vn/vi/currency/converter-EEK-XAG>; rel='alternate'; hreflang='vi-VN'\n" + "Link: <http://www.forexticket.de/de/waehrungsumrechner/devisen-EEK-XAG>; rel='alternate'; hreflang='de-DE'\n" + "Link: <http://www.forexticket.be/de/waehrungsumrechner/devisen-EEK-XAG>; rel='alternate'; hreflang='de-BE'\n" + "Link: <http://www.forexticket.at/de/waehrungsumrechner/devisen-EEK-XAG>; rel='alternate'; hreflang='de-AT'\n" + "Link: <http://www.forexticket.ch/de/waehrungsumrechner/devisen-EEK-XAG>; rel='alternate'; hreflang='de-CH'\n" + "Link: <http://www.forexticket.lu/de/waehrungsumrechner/devisen-EEK-XAG>; rel='alternate'; hreflang='de-LU'\n" + "Link: <http://www.forexticket.li/de/waehrungsumrechner/devisen-EEK-XAG>; rel='alternate'; hreflang='de-LI'\n" + "Link: <http://www.forexticket.de/de/waehrungsumrechner/devisen-EEK-XAG>; rel='canonical'\n" + "Link: <http://www.forexticket-eg.com/ar/currency/converter-EEK-XAG>; rel='alternate'; hreflang='ar-EG'\n" + "Link: <http://www.forexticket-dz.com/ar/currency/converter-EEK-XAG>; rel='alternate'; hreflang='ar-DZ'\n" + "Link: <http://www.forexticket-ma.com/ar/currency/converter-EEK-XAG>; rel='alternate'; hreflang='ar-MA'\n" + "Link: <http://www.forexticket-iq.com/ar/currency/converter-EEK-XAG>; rel='alternate'; hreflang='ar-IQ'\n" + "Link: <http://www.forexticket-sa.com/ar/currency/converter-EEK-XAG>; rel='alternate'; hreflang='ar-SA'\n" + "Link: <http://www.forexticket-sy.com/ar/currency/converter-EEK-XAG>; rel='alternate'; hreflang='ar-SY'\n" + "Link: <http://www.forexticket-tn.com/ar/currency/converter-EEK-XAG>; rel='alternate'; hreflang='ar-TN'\n" + "Link: <http://www.forexticket-td.com/ar/currency/converter-EEK-XAG>; rel='alternate'; hreflang='ar-TD'\n" + "Link: <http://www.forexticket-so.com/ar/currency/converter-EEK-XAG>; rel='alternate'; hreflang='ar-SO'\n" + "Link: <http://www.forexticket.co.il/ar/currency/converter-EEK-XAG>; rel='alternate'; hreflang='ar-IL'\n" + "Link: <http://www.forexticket-jo.com/ar/currency/converter-EEK-XAG>; rel='alternate'; hreflang='ar-JO'\n" + "Link: <http://www.forexticket.ae/ar/currency/converter-EEK-XAG>; rel='alternate'; hreflang='ar-AE'\n" + "Link: <http://www.forexticket-lb.com/ar/currency/converter-EEK-XAG>; rel='alternate'; hreflang='ar-LB'\n" + "Link: <http://www.forexticket-om.com/ar/currency/converter-EEK-XAG>; rel='alternate'; hreflang='ar-OM'\n" + "Link: <http://www.forexticket-kw.com/ar/currency/converter-EEK-XAG>; rel='alternate'; hreflang='ar-KW'\n" + "Link: <http://www.forexticket-tr.com/tr/currency/converter-EEK-XAG>; rel='alternate'; hreflang='tr-TR'\n" + "Link: <http://www.forexticket-bg.com/tr/currency/converter-EEK-XAG>; rel='alternate'; hreflang='tr-BG'\n" + "Link: <http://www.forexticket-cy.com/tr/currency/converter-EEK-XAG>; rel='alternate'; hreflang='tr-CY'\n" + "Link: <http://www.forexticket.ir/fa/currency/converter-EEK-XAG>; rel='alternate'; hreflang='fa-IR'\n" + "Link: <http://www.forexticket.af/fa/currency/converter-EEK-XAG>; rel='alternate'; hreflang='fa-AF'\n" + "Link: <http://www.forexticket.cd/fr/conversion/monnaie-EEK-XAG>; rel='alternate'; hreflang='fr-CD'\n" + "Link: <http://www.forexticket.fr/fr/conversion/monnaie-EEK-XAG>; rel='alternate'; hreflang='fr-FR'\n" + "Link: <http://www.forexticket.com/fr/conversion/monnaie-EEK-XAG>; rel='alternate'; hreflang='fr-CA'\n" + "Link: <http://www.forexticket.mg/fr/conversion/monnaie-EEK-XAG>; rel='alternate'; hreflang='fr-MG'\n" + "Link: <http://www.forexticket.cm/fr/conversion/monnaie-EEK-XAG>; rel='alternate'; hreflang='fr-CM'\n" + "Link: <http://www.forexticket-kh.com/fr/conversion/monnaie-EEK-XAG>; rel='alternate'; hreflang='fr-KH'\n" + "Link: <http://www.forexticket-ml.com/fr/conversion/monnaie-EEK-XAG>; rel='alternate'; hreflang='fr-ML'\n" + "Link: <http://www.forexticket-sn.com/fr/conversion/monnaie-EEK-XAG>; rel='alternate'; hreflang='fr-SN'\n" + "Link: <http://www.forexticket-tn.com/fr/conversion/monnaie-EEK-XAG>; rel='alternate'; hreflang='fr-TN'\n" + "Link: <http://www.forexticket-td.com/fr/conversion/monnaie-EEK-XAG>; rel='alternate'; hreflang='fr-TD'\n" + "Link: <http://www.forexticket.be/fr/conversion/monnaie-EEK-XAG>; rel='alternate'; hreflang='fr-BE'\n" + "Link: <http://www.forexticket-gn.com/fr/conversion/monnaie-EEK-XAG>; rel='alternate'; hreflang='fr-GN'\n" + "Link: <http://www.forexticket.ht/fr/conversion/monnaie-EEK-XAG>; rel='alternate'; hreflang='fr-HT'\n" + "Link: <http://www.forexticket.ch/fr/conversion/monnaie-EEK-XAG>; rel='alternate'; hreflang='fr-CH'\n" + "Link: <http://www.forexticket.la/fr/conversion/monnaie-EEK-XAG>; rel='alternate'; hreflang='fr-LA'\n" + "Link: <http://www.forexticket.lu/fr/conversion/monnaie-EEK-XAG>; rel='alternate'; hreflang='fr-LU'\n" + "Link: <http://www.forexticket-th.com/th/currency/converter-EEK-XAG>; rel='alternate'; hreflang='th-TH'\n" + "Link: <http://www.forexticket.co.uk/cy/currency/converter-EEK-XAG>; rel='alternate'; hreflang='cy-GB'\n" + "Link: <http://www.forexticket.co.uk/ga/currency/converter-EEK-XAG>; rel='alternate'; hreflang='ga-GB'\n" + "Link: <http://www.forexticket.it/it/convertitore/valuta-EEK-XAG>; rel='alternate'; hreflang='it-IT'\n" + "Link: <http://www.forexticket.ch/it/convertitore/valuta-EEK-XAG>; rel='alternate'; hreflang='it-CH'\n" + "Link: <http://www.forexticket.co.za/af/currency/converter-EEK-XAG>; rel='alternate'; hreflang='af-ZA'\n" + "Link: <http://www.forexticket.kr/ko/currency/converter-EEK-XAG>; rel='alternate'; hreflang='ko-KR'\n" + "Link: <http://www.forexticket-ua.com/uk/currency/converter-EEK-XAG>; rel='alternate'; hreflang='uk-UA'\n" + "Link: <http://www.forexticket-tz.com/sw/currency/converter-EEK-XAG>; rel='alternate'; hreflang='sw-TZ'\n" + "Link: <http://www.forexticket.co.ke/sw/currency/converter-EEK-XAG>; rel='alternate'; hreflang='sw-KE'\n" + "Link: <http://www.forexticket.pl/pl/currency/converter-EEK-XAG>; rel='alternate'; hreflang='pl-PL'\n" + "Link: <http://www.forexticket.com.my/ms/currency/converter-EEK-XAG>; rel='alternate'; hreflang='ms-MY'\n" + "Link: <http://www.forexticket.sg/ms/currency/converter-EEK-XAG>; rel='alternate'; hreflang='ms-SG'\n" + "Link: <http://www.forexticket.ro/ro/currency/converter-EEK-XAG>; rel='alternate'; hreflang='ro-RO'\n" + "Link: <http://www.forexticket.nl/nl/currency/converter-EEK-XAG>; rel='alternate'; hreflang='nl-NL'\n" + "Link: <http://www.forexticket.be/nl/currency/converter-EEK-XAG>; rel='alternate'; hreflang='nl-BE'\n" + "Link: <http://www.forexticket.gr/el/currency/converter-EEK-XAG>; rel='alternate'; hreflang='el-GR'\n" + "Link: <http://www.forexticket-al.com/el/currency/converter-EEK-XAG>; rel='alternate'; hreflang='el-AL'\n" + "Link: <http://www.forexticket-cy.com/el/currency/converter-EEK-XAG>; rel='alternate'; hreflang='el-CY'\n" + "Link: <http://www.forexticket.cz/cs/currency/converter-EEK-XAG>; rel='alternate'; hreflang='cs-CZ'\n" + "Link: <http://www.forexticket.hu/hu/currency/converter-EEK-XAG>; rel='alternate'; hreflang='hu-HU'\n" + "Link: <http://www.forexticket.se/sv/currency/converter-EEK-XAG>; rel='alternate'; hreflang='sv-SE'\n" + "Link: <http://www.forexticket.eu/sv/currency/converter-EEK-XAG>; rel='alternate'; hreflang='sv-FI'\n" + "Link: <http://www.forexticket.co.il/iw/currency/converter-EEK-XAG>; rel='alternate'; hreflang='iw-IL'\n" + "Link: <http://www.forexticket.co.il/yi/currency/converter-EEK-XAG>; rel='alternate'; hreflang='yi-IL'\n" + "Link: <http://www.forexticket-bg.com/bg/currency/converter-EEK-XAG>; rel='alternate'; hreflang='bg-BG'\n" + "Link: <http://www.forexticket.es/ca/currency/converter-EEK-XAG>; rel='alternate'; hreflang='ca-ES'\n" + "Link: <http://www.forexticket.es/gl/currency/converter-EEK-XAG>; rel='alternate'; hreflang='gl-ES'\n" + "Link: <http://www.forexticket.dk/da/currency/converter-EEK-XAG>; rel='alternate'; hreflang='da-DK'\n" + "Link: <http://www.forexticket.eu/fi/currency/converter-EEK-XAG>; rel='alternate'; hreflang='fi-FI'\n" + "Link: <http://www.forexticket-hr.com/hr/currency/converter-EEK-XAG>; rel='alternate'; hreflang='hr-HR'\n" + "Link: <http://www.forexticket-hr.com/sr/currency/converter-EEK-XAG>; rel='alternate'; hreflang='sr-HR'\n" + "Link: <http://www.forexticket.me/sr/currency/converter-EEK-XAG>; rel='alternate'; hreflang='sr-ME'\n" + "Link: <http://www.forexticket.lt/lt/currency/converter-EEK-XAG>; rel='alternate'; hreflang='lt-LT'\n" + "Link: <http://www.forexticket-al.com/sq/currency/converter-EEK-XAG>; rel='alternate'; hreflang='sq-AL'\n" + "Link: <http://www.forexticket.lv/lv/currency/converter-EEK-XAG>; rel='alternate'; hreflang='lv-LV'\n" + "Link: <http://www.forexticket.co.ee/et/currency/converter-EEK-XAG>; rel='alternate'; hreflang='et-EE'\n" + "Vary: Accept-Encoding,User-Agent\n" + "Content-Encoding: gzip\n" + "Keep-Alive: timeout=1, max=100\n" + "Connection: Keep-Alive\n" + "Transfer-Encoding: chunked\n" + "Content-Type: text/html\n" + "\n"; diff --git a/library/cpp/http/fetch/ya.make b/library/cpp/http/fetch/ya.make index 9962b82ee1..7737127463 100644 --- a/library/cpp/http/fetch/ya.make +++ b/library/cpp/http/fetch/ya.make @@ -1,19 +1,19 @@ -LIBRARY() +LIBRARY() OWNER( g:zora ) -PEERDIR( - contrib/libs/zlib +PEERDIR( + contrib/libs/zlib library/cpp/charset library/cpp/digest/md5 library/cpp/http/misc library/cpp/logger library/cpp/mime/types library/cpp/uri -) - +) + SRCS( http_digest.cpp http_socket.cpp @@ -32,7 +32,7 @@ SRCS( GENERATE_ENUM_SERIALIZATION(httpheader.h) SET(RAGEL6_FLAGS -CF1) - + END() RECURSE_FOR_TESTS(ut) |