webservices: Use wide character string literals.

Signed-off-by: Hans Leidekker <hans@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Hans Leidekker 2020-03-17 15:35:42 +01:00 committed by Alexandre Julliard
parent f056355071
commit e1b74133b8
4 changed files with 27 additions and 49 deletions

View File

@ -910,8 +910,6 @@ error:
static HRESULT connect_channel_http( struct channel *channel )
{
static const WCHAR agentW[] =
{'M','S','-','W','e','b','S','e','r','v','i','c','e','s','/','1','.','0',0};
HINTERNET ses = NULL, con = NULL;
URL_COMPONENTS uc;
HRESULT hr;
@ -943,7 +941,7 @@ static HRESULT connect_channel_http( struct channel *channel )
goto done;
}
if (!(ses = WinHttpOpen( agentW, 0, NULL, NULL, 0 )))
if (!(ses = WinHttpOpen( L"MS-WebServices/1.0", 0, NULL, NULL, 0 )))
{
hr = HRESULT_FROM_WIN32( GetLastError() );
goto done;
@ -1267,8 +1265,7 @@ static HRESULT send_sized_envelope( struct channel *channel, BYTE *data, ULONG l
static HRESULT open_http_request( struct channel *channel, HINTERNET *req )
{
static const WCHAR postW[] = {'P','O','S','T',0};
if ((*req = WinHttpOpenRequest( channel->u.http.connect, postW, channel->u.http.path,
if ((*req = WinHttpOpenRequest( channel->u.http.connect, L"POST", channel->u.http.path,
NULL, NULL, NULL, channel->u.http.flags ))) return S_OK;
return HRESULT_FROM_WIN32( GetLastError() );
}

View File

@ -286,7 +286,6 @@ void WINAPI WsFreeListener( WS_LISTENER *handle )
HRESULT resolve_hostname( const WCHAR *host, USHORT port, struct sockaddr *addr, int *addr_len, int flags )
{
static const WCHAR fmtW[] = {'%','u',0};
WCHAR service[6];
ADDRINFOW hints, *res, *info;
HRESULT hr = WS_E_ADDRESS_NOT_AVAILABLE;
@ -296,7 +295,7 @@ HRESULT resolve_hostname( const WCHAR *host, USHORT port, struct sockaddr *addr,
hints.ai_family = AF_INET;
*addr_len = 0;
swprintf( service, ARRAY_SIZE(service), fmtW, port );
swprintf( service, ARRAY_SIZE(service), L"%u", port );
if (GetAddrInfoW( host, service, &hints, &res )) return HRESULT_FROM_WIN32( WSAGetLastError() );
info = res;

View File

@ -1901,14 +1901,6 @@ static HRESULT insert_mapped_headers( struct msg *msg, HINTERNET req )
HRESULT message_insert_http_headers( WS_MESSAGE *handle, HINTERNET req )
{
static const WCHAR contenttypeW[] =
{'C','o','n','t','e','n','t','-','T','y','p','e',0};
static const WCHAR soapxmlW[] =
{'a','p','p','l','i','c','a','t','i','o','n','/','s','o','a','p','+','x','m','l',0};
static const WCHAR textxmlW[] =
{'t','e','x','t','/','x','m','l',0};
static const WCHAR charsetW[] =
{'c','h','a','r','s','e','t','=','u','t','f','-','8',0};
struct msg *msg = (struct msg *)handle;
HRESULT hr = E_OUTOFMEMORY;
WCHAR *header = NULL, *buf;
@ -1925,11 +1917,11 @@ HRESULT message_insert_http_headers( WS_MESSAGE *handle, HINTERNET req )
switch (msg->version_env)
{
case WS_ENVELOPE_VERSION_SOAP_1_1:
header = build_http_header( contenttypeW, textxmlW, &len );
header = build_http_header( L"Content-Type", L"text/xml", &len );
break;
case WS_ENVELOPE_VERSION_SOAP_1_2:
header = build_http_header( contenttypeW, soapxmlW, &len );
header = build_http_header( L"Content-Type", L"application/soap+xml", &len );
break;
default:
@ -1942,7 +1934,7 @@ HRESULT message_insert_http_headers( WS_MESSAGE *handle, HINTERNET req )
heap_free( header );
hr = E_OUTOFMEMORY;
if (!(header = build_http_header( contenttypeW, charsetW, &len ))) goto done;
if (!(header = build_http_header( L"Content-Type", L"charset=utf-8", &len ))) goto done;
if ((hr = insert_http_header( req, header, len, WINHTTP_ADDREQ_FLAG_COALESCE_WITH_SEMICOLON )) != S_OK)
goto done;
heap_free( header );
@ -1952,8 +1944,6 @@ HRESULT message_insert_http_headers( WS_MESSAGE *handle, HINTERNET req )
{
case WS_ENVELOPE_VERSION_SOAP_1_1:
{
static const WCHAR soapactionW[] = {'S','O','A','P','A','c','t','i','o','n',0};
if (!(len = MultiByteToWideChar( CP_UTF8, 0, (char *)msg->action->bytes, msg->action->length, NULL, 0 )))
break;
@ -1964,7 +1954,7 @@ HRESULT message_insert_http_headers( WS_MESSAGE *handle, HINTERNET req )
buf[len + 1] = '"';
buf[len + 2] = 0;
header = build_http_header( soapactionW, buf, &len );
header = build_http_header( L"SOAPAction", buf, &len );
heap_free( buf );
if (!header) goto done;
@ -1973,21 +1963,20 @@ HRESULT message_insert_http_headers( WS_MESSAGE *handle, HINTERNET req )
}
case WS_ENVELOPE_VERSION_SOAP_1_2:
{
static const WCHAR actionW[] = {'a','c','t','i','o','n','=','"'};
ULONG len_action = ARRAY_SIZE( actionW );
ULONG len_action = ARRAY_SIZE( L"action=\"" ) - 1;
if (!(len = MultiByteToWideChar( CP_UTF8, 0, (char *)msg->action->bytes, msg->action->length, NULL, 0 )))
break;
hr = E_OUTOFMEMORY;
if (!(buf = heap_alloc( (len + len_action + 2) * sizeof(WCHAR) ))) goto done;
memcpy( buf, actionW, len_action * sizeof(WCHAR) );
memcpy( buf, L"action=\"", len_action * sizeof(WCHAR) );
MultiByteToWideChar( CP_UTF8, 0, (char *)msg->action->bytes, msg->action->length, buf + len_action, len );
len += len_action;
buf[len++] = '"';
buf[len] = 0;
header = build_http_header( contenttypeW, buf, &len );
header = build_http_header( L"Content-Type", buf, &len );
heap_free( buf );
if (!header) goto done;

View File

@ -31,27 +31,21 @@
WINE_DEFAULT_DEBUG_CHANNEL(webservices);
static const WCHAR http[] = {'h','t','t','p'};
static const WCHAR https[] = {'h','t','t','p','s'};
static const WCHAR nettcp[] = {'n','e','t','.','t','c','p'};
static const WCHAR soapudp[] = {'s','o','a','p','.','u','d','p'};
static const WCHAR netpipe[] = {'n','e','t','.','p','i','p','e'};
static WS_URL_SCHEME_TYPE scheme_type( const WCHAR *str, ULONG len )
{
if (len == ARRAY_SIZE( http ) && !wcsnicmp( str, http, ARRAY_SIZE( http )))
if (len == ARRAY_SIZE( L"http" ) - 1 && !wcsnicmp( str, L"http", ARRAY_SIZE( L"http" ) - 1 ))
return WS_URL_HTTP_SCHEME_TYPE;
if (len == ARRAY_SIZE( https ) && !wcsnicmp( str, https, ARRAY_SIZE( https )))
if (len == ARRAY_SIZE( L"https" ) - 1 && !wcsnicmp( str, L"https", ARRAY_SIZE( L"https" ) - 1 ))
return WS_URL_HTTPS_SCHEME_TYPE;
if (len == ARRAY_SIZE( nettcp ) && !wcsnicmp( str, nettcp, ARRAY_SIZE( nettcp )))
if (len == ARRAY_SIZE( L"net.tcp" ) - 1 && !wcsnicmp( str, L"net.tcp", ARRAY_SIZE( L"net.tcp" ) - 1 ))
return WS_URL_NETTCP_SCHEME_TYPE;
if (len == ARRAY_SIZE( soapudp ) && !wcsnicmp( str, soapudp, ARRAY_SIZE( soapudp )))
if (len == ARRAY_SIZE( L"soap.udp" ) - 1 && !wcsnicmp( str, L"soap.udp", ARRAY_SIZE( L"soap.udp" ) - 1 ))
return WS_URL_SOAPUDP_SCHEME_TYPE;
if (len == ARRAY_SIZE( netpipe ) && !wcsnicmp( str, netpipe, ARRAY_SIZE( netpipe )))
if (len == ARRAY_SIZE( L"net.pipe" ) - 1 && !wcsnicmp( str, L"net.pipe", ARRAY_SIZE( L"net.pipe" ) - 1 ))
return WS_URL_NETPIPE_SCHEME_TYPE;
return ~0u;
@ -278,24 +272,24 @@ static const WCHAR *scheme_str( WS_URL_SCHEME_TYPE scheme, ULONG *len )
switch (scheme)
{
case WS_URL_HTTP_SCHEME_TYPE:
*len = ARRAY_SIZE( http );
return http;
*len = ARRAY_SIZE( L"http" ) - 1;
return L"http";
case WS_URL_HTTPS_SCHEME_TYPE:
*len = ARRAY_SIZE( https );
return https;
*len = ARRAY_SIZE( L"https" ) - 1;
return L"https";
case WS_URL_NETTCP_SCHEME_TYPE:
*len = ARRAY_SIZE( nettcp );
return nettcp;
*len = ARRAY_SIZE( L"net.tcp" ) - 1;
return L"net.tcp";
case WS_URL_SOAPUDP_SCHEME_TYPE:
*len = ARRAY_SIZE( soapudp );
return soapudp;
*len = ARRAY_SIZE( L"soap.udp" ) - 1;
return L"soap.udp";
case WS_URL_NETPIPE_SCHEME_TYPE:
*len = ARRAY_SIZE( netpipe );
return netpipe;
*len = ARRAY_SIZE( L"net.pipe" ) - 1;
return L"net.pipe";
default:
ERR( "unhandled scheme %u\n", scheme );
@ -364,7 +358,7 @@ static HRESULT url_encode_size( const WCHAR *str, ULONG len, const char *except,
static ULONG url_encode_byte( unsigned char byte, const char *except, WCHAR *buf )
{
static const WCHAR hex[] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
static const WCHAR hex[] = L"0123456789ABCDEF";
switch (escape_size( byte, except ))
{
case 3:
@ -426,7 +420,6 @@ static HRESULT url_encode( const WCHAR *str, ULONG len, WCHAR *buf, const char *
HRESULT WINAPI WsEncodeUrl( const WS_URL *base, ULONG flags, WS_HEAP *heap, WS_STRING *ret,
WS_ERROR *error )
{
static const WCHAR fmtW[] = {':','%','u',0};
ULONG len = 0, len_scheme, len_enc, ret_size = 0;
const WS_HTTP_URL *url = (const WS_HTTP_URL *)base;
const WCHAR *scheme;
@ -504,7 +497,7 @@ HRESULT WINAPI WsEncodeUrl( const WS_URL *base, ULONG flags, WS_HEAP *heap, WS_S
if (port)
{
WCHAR buf[7];
len = swprintf( buf, ARRAY_SIZE(buf), fmtW, port );
len = swprintf( buf, ARRAY_SIZE(buf), L":%u", port );
memcpy( p, buf, len * sizeof(WCHAR) );
p += len;
}