ReactOS  0.4.13-dev-241-g63286c6
url.c File Reference
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "winnls.h"
#include "winhttp.h"
#include "wine/test.h"
Include dependency graph for url.c:

Go to the source code of this file.

Functions

static void fill_url_components (URL_COMPONENTS *uc)
 
static void WinHttpCreateUrl_test (void)
 
static void reset_url_components (URL_COMPONENTS *uc)
 
static void WinHttpCrackUrl_test (void)
 
 START_TEST (url)
 

Variables

static WCHAR empty [] = {0}
 
static WCHAR ftp [] = {'f','t','p',0}
 
static WCHAR http [] = {'h','t','t','p',0}
 
static WCHAR winehq [] = {'w','w','w','.','w','i','n','e','h','q','.','o','r','g',0}
 
static WCHAR username [] = {'u','s','e','r','n','a','m','e',0}
 
static WCHAR password [] = {'p','a','s','s','w','o','r','d',0}
 
static WCHAR about [] = {'/','s','i','t','e','/','a','b','o','u','t',0}
 
static WCHAR query [] = {'?','q','u','e','r','y',0}
 
static WCHAR escape [] = {' ','!','"','#','$','%','&','\'','(',')','*','+',',','-','.','/',':',';','<','=','>','?','@','[','\\',']','^','_','`','{','|','}','~',0}
 
static const WCHAR url1 []
 
static const WCHAR url2 [] = {'h','t','t','p',':','/','/','u','s','e','r','n','a','m','e',':',0}
 
static const WCHAR url3 []
 
static const WCHAR url4 [] = {'h','t','t','p',':','/','/',0}
 
static const WCHAR url5 []
 
static const WCHAR url6 []
 
static const WCHAR url7 []
 
static const WCHAR url8 []
 
static const WCHAR url9 []
 
static const WCHAR url10 []
 
static const WCHAR url11 []
 
static const WCHAR url12 []
 
static const WCHAR url13 []
 
static const WCHAR url14 [] = {'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q','.','o','r','g','/','t','e','s','t',0}
 
static const WCHAR url15 [] = {'h','t','t','p',':','/','/','w','i','n','e','h','q','.','o','r','g',':','6','5','5','3','6',0}
 
static const WCHAR url16 [] = {'h','t','t','p',':','/','/','w','i','n','e','h','q','.','o','r','g',':','0',0}
 
static const WCHAR url17 [] = {'h','t','t','p',':','/','/','w','i','n','e','h','q','.','o','r','g',':',0}
 
static const WCHAR url_k1 []
 
static const WCHAR url_k2 []
 
static const WCHAR url_k3 []
 
static const WCHAR url_k4 []
 
static const WCHAR url_k5 []
 
static const WCHAR url_k6 []
 
static const WCHAR url_k7 []
 
static const WCHAR url_k8 []
 
static const WCHAR url_k9 []
 
static const WCHAR url_k10 []
 

Function Documentation

◆ fill_url_components()

static void fill_url_components ( URL_COMPONENTS uc)
static

Definition at line 98 of file url.c.

99 {
100  uc->dwStructSize = sizeof(URL_COMPONENTS);
101  uc->lpszScheme = http;
102  uc->dwSchemeLength = lstrlenW( uc->lpszScheme );
104  uc->lpszHostName = winehq;
106  uc->nPort = 80;
107  uc->lpszUserName = username;
109  uc->lpszPassword = password;
111  uc->lpszUrlPath = about;
112  uc->dwUrlPathLength = lstrlenW( uc->lpszUrlPath );
113  uc->lpszExtraInfo = query;
115 }
LPWSTR lpszExtraInfo
Definition: winhttp.h:478
DWORD dwHostNameLength
Definition: winhttp.h:470
LPWSTR lpszUrlPath
Definition: winhttp.h:476
DWORD dwUserNameLength
Definition: winhttp.h:473
DWORD dwUrlPathLength
Definition: winhttp.h:477
#define lstrlenW
Definition: compat.h:407
DWORD dwSchemeLength
Definition: winhttp.h:467
static WCHAR password[]
Definition: url.c:33
INTERNET_SCHEME nScheme
Definition: winhttp.h:468
static WCHAR username[]
Definition: url.c:32
DWORD dwExtraInfoLength
Definition: winhttp.h:479
static WCHAR query[]
Definition: url.c:35
DWORD dwStructSize
Definition: winhttp.h:465
INTERNET_PORT nPort
Definition: winhttp.h:471
LPWSTR lpszUserName
Definition: winhttp.h:472
LPWSTR lpszHostName
Definition: winhttp.h:469
static WCHAR http[]
Definition: url.c:30
LPWSTR lpszPassword
Definition: winhttp.h:474
static WCHAR winehq[]
Definition: url.c:31
DWORD dwPasswordLength
Definition: winhttp.h:475
static WCHAR about[]
Definition: url.c:34
LPWSTR lpszScheme
Definition: winhttp.h:466

Referenced by WinHttpCreateUrl_test().

◆ reset_url_components()

static void reset_url_components ( URL_COMPONENTS uc)
static

Definition at line 322 of file url.c.

323 {
324  memset( uc, 0, sizeof(URL_COMPONENTS) );
325  uc->dwStructSize = sizeof(URL_COMPONENTS);
326  uc->dwSchemeLength = ~0u;
327  uc->dwHostNameLength = 1;
328  uc->nPort = 0;
329  uc->dwUserNameLength = ~0u;
330  uc->dwPasswordLength = ~0u;
331  uc->dwUrlPathLength = ~0u;
332  uc->dwExtraInfoLength = ~0u;
333 }
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
DWORD dwHostNameLength
Definition: winhttp.h:470
DWORD dwUserNameLength
Definition: winhttp.h:473
DWORD dwUrlPathLength
Definition: winhttp.h:477
DWORD dwSchemeLength
Definition: winhttp.h:467
DWORD dwExtraInfoLength
Definition: winhttp.h:479
DWORD dwStructSize
Definition: winhttp.h:465
INTERNET_PORT nPort
Definition: winhttp.h:471
DWORD dwPasswordLength
Definition: winhttp.h:475
#define memset(x, y, z)
Definition: compat.h:39

Referenced by WinHttpCrackUrl_test().

◆ START_TEST()

START_TEST ( url  )

Definition at line 758 of file url.c.

759 {
762 }
static void WinHttpCreateUrl_test(void)
Definition: url.c:117
static void WinHttpCrackUrl_test(void)
Definition: url.c:335

◆ WinHttpCrackUrl_test()

static void WinHttpCrackUrl_test ( void  )
static

Definition at line 335 of file url.c.

336 {
337  static const WCHAR hostnameW[] =
338  {'w','i','n','e','h','q','.','o',' ','g',0};
339  static const WCHAR pathW[] =
340  {'/','p','a','t','h','%','2','0','w','i','t','h','%','2','0','s','p','a','c','e','s',0};
341  URL_COMPONENTSW uc;
342  WCHAR scheme[20], user[20], pass[20], host[20], path[80], extra[40];
343  DWORD error;
344  BOOL ret;
345 
346  /* buffers of sufficient length */
347  scheme[0] = user[0] = pass[0] = host[0] = path[0] = extra[0] = 0;
348 
349  uc.dwStructSize = sizeof(URL_COMPONENTS);
350  uc.nScheme = 0;
351  uc.lpszScheme = scheme;
352  uc.dwSchemeLength = 20;
353  uc.lpszUserName = user;
354  uc.dwUserNameLength = 20;
355  uc.lpszPassword = pass;
356  uc.dwPasswordLength = 20;
357  uc.lpszHostName = host;
358  uc.dwHostNameLength = 20;
359  uc.nPort = 0;
360  uc.lpszUrlPath = path;
361  uc.dwUrlPathLength = 40;
362  uc.lpszExtraInfo = extra;
363  uc.dwExtraInfoLength = 20;
364 
365  ret = WinHttpCrackUrl( url1, 0, 0, &uc );
366  ok( ret, "WinHttpCrackUrl failed le=%u\n", GetLastError() );
367  ok( uc.nScheme == INTERNET_SCHEME_HTTP, "unexpected scheme: %u\n", uc.nScheme );
368  ok( !memcmp( uc.lpszScheme, http, sizeof(http) ), "unexpected scheme: %s\n", wine_dbgstr_w(uc.lpszScheme) );
369  ok( uc.dwSchemeLength == 4, "unexpected scheme length: %u\n", uc.dwSchemeLength );
370  ok( !memcmp( uc.lpszUserName, username, sizeof(username) ), "unexpected username: %s\n", wine_dbgstr_w(uc.lpszUserName) );
371  ok( uc.dwUserNameLength == 8, "unexpected username length: %u\n", uc.dwUserNameLength );
372  ok( !memcmp( uc.lpszPassword, password, sizeof(password) ), "unexpected password: %s\n", wine_dbgstr_w(uc.lpszPassword) );
373  ok( uc.dwPasswordLength == 8, "unexpected password length: %u\n", uc.dwPasswordLength );
374  ok( !memcmp( uc.lpszHostName, winehq, sizeof(winehq) ), "unexpected hostname: %s\n", wine_dbgstr_w(uc.lpszHostName) );
375  ok( uc.dwHostNameLength == 14, "unexpected hostname length: %u\n", uc.dwHostNameLength );
376  ok( uc.nPort == 80, "unexpected port: %u\n", uc.nPort );
377  ok( !memcmp( uc.lpszUrlPath, about, sizeof(about) ), "unexpected path: %s\n", wine_dbgstr_w(uc.lpszUrlPath) );
378  ok( uc.dwUrlPathLength == 11, "unexpected path length: %u\n", uc.dwUrlPathLength );
379  ok( !memcmp( uc.lpszExtraInfo, query, sizeof(query) ), "unexpected extra info: %s\n", wine_dbgstr_w(uc.lpszExtraInfo) );
380  ok( uc.dwExtraInfoLength == 6, "unexpected extra info length: %u\n", uc.dwExtraInfoLength );
381 
382  /* buffers of insufficient length */
383  uc.dwSchemeLength = 1;
384  uc.dwHostNameLength = 1;
385  uc.dwUrlPathLength = 40; /* sufficient */
386  SetLastError( 0xdeadbeef );
387  ret = WinHttpCrackUrl( url1, 0, 0, &uc );
388  error = GetLastError();
389  ok( !ret, "WinHttpCrackUrl succeeded\n" );
390  ok( error == ERROR_INSUFFICIENT_BUFFER, "got %u, expected ERROR_INSUFFICIENT_BUFFER\n", error );
391  ok( uc.dwSchemeLength == 5, "unexpected scheme length: %u\n", uc.dwSchemeLength );
392  ok( uc.dwHostNameLength == 15, "unexpected hostname length: %u\n", uc.dwHostNameLength );
393  ok( uc.dwUrlPathLength == 11, "unexpected path length: %u\n", uc.dwUrlPathLength );
394 
395  /* no buffers */
396  reset_url_components( &uc );
397  SetLastError( 0xdeadbeef );
398  ret = WinHttpCrackUrl( url_k1, 0, 0, &uc);
399  error = GetLastError();
400  ok( ret, "WinHttpCrackUrl failed le=%u\n", error );
401  ok( error == ERROR_SUCCESS || broken(error == ERROR_INVALID_PARAMETER) /* < win7 */,
402  "got %u, expected ERROR_SUCCESS\n", error );
403  ok( uc.nScheme == INTERNET_SCHEME_HTTP, "unexpected scheme\n" );
404  ok( uc.lpszScheme == url_k1,"unexpected scheme\n" );
405  ok( uc.dwSchemeLength == 4, "unexpected scheme length\n" );
406  ok( uc.lpszUserName == url_k1 + 7, "unexpected username\n" );
407  ok( uc.dwUserNameLength == 8, "unexpected username length\n" );
408  ok( uc.lpszPassword == url_k1 + 16, "unexpected password\n" );
409  ok( uc.dwPasswordLength == 8, "unexpected password length\n" );
410  ok( uc.lpszHostName == url_k1 + 25, "unexpected hostname\n" );
411  ok( uc.dwHostNameLength == 14, "unexpected hostname length\n" );
412  ok( uc.nPort == 80, "unexpected port: %u\n", uc.nPort );
413  ok( uc.lpszUrlPath == url_k1 + 39, "unexpected path\n" );
414  ok( uc.dwUrlPathLength == 11, "unexpected path length\n" );
415  ok( uc.lpszExtraInfo == url_k1 + 50, "unexpected extra info\n" );
416  ok( uc.dwExtraInfoLength == 0, "unexpected extra info length\n" );
417 
418  reset_url_components( &uc );
421  ret = WinHttpCrackUrl( url_k2, 0, 0,&uc);
422  ok( ret, "WinHttpCrackUrl failed le=%u\n", GetLastError() );
423  ok( uc.nScheme == INTERNET_SCHEME_HTTP, "unexpected scheme\n" );
424  ok( uc.lpszScheme == url_k2, "unexpected scheme\n" );
425  ok( uc.dwSchemeLength == 4, "unexpected scheme length\n" );
426  ok( uc.lpszUserName == NULL ,"unexpected username\n" );
427  ok( uc.dwUserNameLength == 0, "unexpected username length\n" );
428  ok( uc.lpszPassword == NULL, "unexpected password\n" );
429  ok( uc.dwPasswordLength == 0, "unexpected password length\n" );
430  ok( uc.lpszHostName == url_k2 + 7, "unexpected hostname\n" );
431  ok( uc.dwHostNameLength == 14, "unexpected hostname length\n" );
432  ok( uc.nPort == 80, "unexpected port: %u\n", uc.nPort );
433  ok( uc.lpszUrlPath == url_k2 + 21, "unexpected path\n" );
434  ok( uc.dwUrlPathLength == 0, "unexpected path length\n" );
435  ok( uc.lpszExtraInfo == url_k2 + 21, "unexpected extra info\n" );
436  ok( uc.dwExtraInfoLength == 0, "unexpected extra info length\n" );
437 
438  reset_url_components( &uc );
439  ret = WinHttpCrackUrl( url_k3, 0, 0, &uc );
440  ok( ret, "WinHttpCrackUrl failed le=%u\n", GetLastError() );
441  ok( uc.nScheme == INTERNET_SCHEME_HTTPS, "unexpected scheme\n" );
442  ok( uc.lpszScheme == url_k3, "unexpected scheme\n" );
443  ok( uc.dwSchemeLength == 5, "unexpected scheme length\n" );
444  ok( uc.lpszUserName == NULL, "unexpected username\n" );
445  ok( uc.dwUserNameLength == 0, "unexpected username length\n" );
446  ok( uc.lpszPassword == NULL, "unexpected password\n" );
447  ok( uc.dwPasswordLength == 0, "unexpected password length\n" );
448  ok( uc.lpszHostName == url_k3 + 8, "unexpected hostname\n" );
449  ok( uc.dwHostNameLength == 14, "unexpected hostname length\n" );
450  ok( uc.nPort == 443, "unexpected port: %u\n", uc.nPort );
451  ok( uc.lpszUrlPath == url_k3 + 22, "unexpected path\n" );
452  ok( uc.dwUrlPathLength == 5, "unexpected path length\n" );
453  ok( uc.lpszExtraInfo == url_k3 + 27, "unexpected extra info\n" );
454  ok( uc.dwExtraInfoLength == 1, "unexpected extra info length\n" );
455 
456  /* bad parameters */
457  reset_url_components( &uc );
458  SetLastError( 0xdeadbeef );
459  ret = WinHttpCrackUrl( url_k4, 0, 0, &uc );
460  ok( !ret, "WinHttpCrackUrl succeeded\n" );
461  error = GetLastError();
462  ok( error == ERROR_WINHTTP_INVALID_URL, "got %u\n", error );
463 
464  reset_url_components( &uc );
465  SetLastError( 0xdeadbeef );
466  ret = WinHttpCrackUrl( url_k5, 0, 0, &uc );
467  ok( !ret, "WinHttpCrackUrl succeeded\n" );
468  error = GetLastError();
469  ok( error == ERROR_WINHTTP_INVALID_URL, "got %u\n", error );
470 
471  reset_url_components( &uc );
472  SetLastError( 0xdeadbeef );
473  ret = WinHttpCrackUrl( url_k6, 0, 0, &uc );
474  ok( !ret, "WinHttpCrackUrl succeeded\n" );
475  error = GetLastError();
476  ok( error == ERROR_WINHTTP_UNRECOGNIZED_SCHEME, "got %u\n", error );
477 
478  reset_url_components( &uc );
479  SetLastError( 0xdeadbeef );
480  ret = WinHttpCrackUrl( url_k7, 0, 0, &uc );
481  ok( !ret, "WinHttpCrackUrl succeeded\n" );
482  error = GetLastError();
483  ok( error == ERROR_WINHTTP_UNRECOGNIZED_SCHEME, "got %u\n", error );
484 
485  reset_url_components( &uc );
486  SetLastError( 0xdeadbeef );
487  ret = WinHttpCrackUrl( url_k8, 0, 0, &uc );
488  error = GetLastError();
489  ok( !ret, "WinHttpCrackUrl succeeded\n" );
490  ok( error == ERROR_WINHTTP_UNRECOGNIZED_SCHEME, "got %u\n", error );
491 
492  reset_url_components( &uc );
493  ret = WinHttpCrackUrl( url_k9, 0, 0, &uc );
494  ok( ret, "WinHttpCrackUrl failed le=%u\n", GetLastError() );
495  ok( uc.lpszUrlPath == url_k9 + 14 || broken(uc.lpszUrlPath == url_k9 + 13) /* win8 */,
496  "unexpected path: %s\n", wine_dbgstr_w(uc.lpszUrlPath) );
497  ok( uc.dwUrlPathLength == 0, "unexpected path length: %u\n", uc.dwUrlPathLength );
498  ok( uc.lpszExtraInfo == url_k9 + 14 || broken(uc.lpszExtraInfo == url_k9 + 13) /* win8 */,
499  "unexpected extra info: %s\n", wine_dbgstr_w(uc.lpszExtraInfo) );
500  ok( uc.dwExtraInfoLength == 0 || broken(uc.dwExtraInfoLength == 1) /* win8 */,
501  "unexpected extra info length: %u\n", uc.dwExtraInfoLength );
502 
503  reset_url_components( &uc );
504  ret = WinHttpCrackUrl( url_k10, 0, 0, &uc );
505  ok( ret, "WinHttpCrackUrl failed le=%u\n", GetLastError() );
506  ok( uc.lpszUrlPath == url_k10 + 13, "unexpected path: %s\n", wine_dbgstr_w(uc.lpszUrlPath) );
507  ok( uc.dwUrlPathLength == 7, "unexpected path length: %u\n", uc.dwUrlPathLength );
508  ok( uc.lpszExtraInfo == url_k10 + 20, "unexpected extra info: %s\n", wine_dbgstr_w(uc.lpszExtraInfo) );
509  ok( uc.dwExtraInfoLength == 0, "unexpected extra info length: %u\n", uc.dwExtraInfoLength );
510 
511  reset_url_components( &uc );
512  SetLastError( 0xdeadbeef );
513  ret = WinHttpCrackUrl( url4, 0, 0, &uc );
514  error = GetLastError();
515  ok( !ret, "WinHttpCrackUrl succeeded\n" );
516  ok( error == ERROR_WINHTTP_INVALID_URL, "got %u\n", error );
517 
518  reset_url_components( &uc );
519  SetLastError( 0xdeadbeef );
520  ret = WinHttpCrackUrl( empty, 0, 0, &uc );
521  error = GetLastError();
522  ok( !ret, "WinHttpCrackUrl succeeded\n" );
523  ok( error == ERROR_WINHTTP_UNRECOGNIZED_SCHEME, "got %u\n", error );
524 
525  SetLastError( 0xdeadbeef );
526  ret = WinHttpCrackUrl( url1, 0, 0, NULL );
527  error = GetLastError();
528  ok( !ret, "WinHttpCrackUrl succeeded\n" );
529  ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
530 
531  SetLastError( 0xdeadbeef );
532  ret = WinHttpCrackUrl( NULL, 0, 0, &uc );
533  error = GetLastError();
534  ok( !ret, "WinHttpCrackUrl succeeded\n" );
535  ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
536 
537  /* decoding without buffers */
538  reset_url_components( &uc );
539  SetLastError(0xdeadbeef);
540  ret = WinHttpCrackUrl( url7, 0, ICU_DECODE, &uc );
541  error = GetLastError();
542  ok( !ret, "WinHttpCrackUrl succeeded\n" );
543  ok( error == ERROR_INVALID_PARAMETER, "got %u, expected ERROR_INVALID_PARAMETER\n", error );
544 
545  /* decoding with buffers */
546  uc.lpszScheme = scheme;
547  uc.dwSchemeLength = 20;
548  uc.lpszUserName = user;
549  uc.dwUserNameLength = 20;
550  uc.lpszPassword = pass;
551  uc.dwPasswordLength = 20;
552  uc.lpszHostName = host;
553  uc.dwHostNameLength = 20;
554  uc.nPort = 0;
555  uc.lpszUrlPath = path;
556  uc.dwUrlPathLength = 80;
557  uc.lpszExtraInfo = extra;
558  uc.dwExtraInfoLength = 40;
559  path[0] = 0;
560 
561  ret = WinHttpCrackUrl( url7, 0, ICU_DECODE, &uc );
562  ok( ret, "WinHttpCrackUrl failed %u\n", GetLastError() );
563  ok( !memcmp( uc.lpszUrlPath + 11, escape, 21 * sizeof(WCHAR) ), "unexpected path\n" );
564  ok( uc.dwUrlPathLength == 32, "unexpected path length %u\n", uc.dwUrlPathLength );
565  ok( !memcmp( uc.lpszExtraInfo, escape + 21, 12 * sizeof(WCHAR) ), "unexpected extra info\n" );
566  ok( uc.dwExtraInfoLength == 12, "unexpected extra info length %u\n", uc.dwExtraInfoLength );
567 
568  /* Urls with specified port numbers */
569  /* decoding with buffers */
570  uc.lpszScheme = scheme;
571  uc.dwSchemeLength = 20;
572  uc.lpszUserName = user;
573  uc.dwUserNameLength = 20;
574  uc.lpszPassword = pass;
575  uc.dwPasswordLength = 20;
576  uc.lpszHostName = host;
577  uc.dwHostNameLength = 20;
578  uc.nPort = 0;
579  uc.lpszUrlPath = path;
580  uc.dwUrlPathLength = 40;
581  uc.lpszExtraInfo = extra;
582  uc.dwExtraInfoLength = 20;
583  path[0] = 0;
584 
585  ret = WinHttpCrackUrl( url6, 0, 0, &uc );
586  ok( ret, "WinHttpCrackUrl failed le=%u\n", GetLastError() );
587  ok( !memcmp( uc.lpszHostName, winehq, sizeof(winehq) ), "unexpected host name: %s\n", wine_dbgstr_w(uc.lpszHostName) );
588  ok( uc.dwHostNameLength == 14, "unexpected host name length: %d\n", uc.dwHostNameLength );
589  ok( uc.nPort == 42, "unexpected port: %u\n", uc.nPort );
590 
591  /* decoding without buffers */
592  reset_url_components( &uc );
593  ret = WinHttpCrackUrl( url8, 0, 0, &uc );
594  ok( ret, "WinHttpCrackUrl failed le=%u\n", GetLastError() );
595  ok( uc.nPort == 0, "unexpected port: %u\n", uc.nPort );
596 
597  reset_url_components( &uc );
598  ret = WinHttpCrackUrl( url9, 0, 0, &uc );
599  ok( ret, "WinHttpCrackUrl failed le=%u\n", GetLastError() );
600  ok( uc.nPort == 80, "unexpected port: %u\n", uc.nPort );
601 
602  reset_url_components( &uc );
603  ret = WinHttpCrackUrl( url10, 0, 0, &uc );
604  ok( ret, "WinHttpCrackUrl failed le=%u\n", GetLastError() );
605  ok( uc.nPort == 443, "unexpected port: %u\n", uc.nPort );
606 
607  reset_url_components( &uc );
608  SetLastError( 0xdeadbeef );
609  ret = WinHttpCrackUrl( empty, 0, 0, &uc );
610  error = GetLastError();
611  ok( !ret, "WinHttpCrackUrl succeeded\n" );
612  ok( error == ERROR_WINHTTP_UNRECOGNIZED_SCHEME, "got %u, expected ERROR_WINHTTP_UNRECOGNIZED_SCHEME\n", error );
613 
614  reset_url_components( &uc );
615  SetLastError( 0xdeadbeef );
616  ret = WinHttpCrackUrl( http, 0, 0, &uc );
617  error = GetLastError();
618  ok( !ret, "WinHttpCrackUrl succeeded\n" );
619  ok( error == ERROR_WINHTTP_UNRECOGNIZED_SCHEME, "got %u, expected ERROR_WINHTTP_UNRECOGNIZED_SCHEME\n", error );
620 
621  reset_url_components( &uc );
622  ret = WinHttpCrackUrl( url11, 0, 0, &uc);
623  ok( ret, "WinHttpCrackUrl failed le=%u\n", GetLastError() );
624  ok( uc.nScheme == INTERNET_SCHEME_HTTP, "unexpected scheme\n" );
625  ok( uc.lpszScheme == url11,"unexpected scheme\n" );
626  ok( uc.dwSchemeLength == 4, "unexpected scheme length\n" );
627  ok( uc.lpszUserName == NULL, "unexpected username\n" );
628  ok( uc.lpszPassword == NULL, "unexpected password\n" );
629  ok( uc.lpszHostName == url11 + 7, "unexpected hostname\n" );
630  ok( uc.dwHostNameLength == 11, "unexpected hostname length\n" );
631  ok( uc.nPort == 80, "unexpected port: %u\n", uc.nPort );
632  ok( uc.lpszUrlPath == url11 + 18, "unexpected path\n" );
633  ok( uc.dwUrlPathLength == 5, "unexpected path length\n" );
634  ok( uc.lpszExtraInfo == url11 + 23, "unexpected extra info\n" );
635  ok( uc.dwExtraInfoLength == 39, "unexpected extra info length\n" );
636 
637  uc.lpszScheme = scheme;
638  uc.dwSchemeLength = 20;
639  uc.lpszHostName = host;
640  uc.dwHostNameLength = 20;
641  uc.lpszUserName = NULL;
642  uc.dwUserNameLength = 0;
643  uc.lpszPassword = NULL;
644  uc.dwPasswordLength = 0;
645  uc.lpszUrlPath = path;
646  uc.dwUrlPathLength = 40;
647  uc.lpszExtraInfo = NULL;
648  uc.dwExtraInfoLength = 0;
649  uc.nPort = 0;
650  ret = WinHttpCrackUrl( url12, 0, ICU_DECODE, &uc );
651  ok( ret, "WinHttpCrackUrl failed le=%u\n", GetLastError() );
652 
653  uc.lpszScheme = scheme;
654  uc.dwSchemeLength = 20;
655  uc.lpszHostName = host;
656  uc.dwHostNameLength = 20;
657  uc.lpszUserName = NULL;
658  uc.dwUserNameLength = 0;
659  uc.lpszPassword = NULL;
660  uc.dwPasswordLength = 0;
661  uc.lpszUrlPath = path;
662  uc.dwUrlPathLength = 40;
663  uc.lpszExtraInfo = NULL;
664  uc.dwExtraInfoLength = 0;
665  uc.nPort = 0;
667  ok( ret, "WinHttpCrackUrl failed le=%u\n", GetLastError() );
668  ok( !lstrcmpW( uc.lpszHostName, hostnameW ), "unexpected host name\n" );
669  ok( !lstrcmpW( uc.lpszUrlPath, pathW ), "unexpected path\n" );
670 
671  uc.dwStructSize = sizeof(uc);
672  uc.lpszScheme = NULL;
673  uc.dwSchemeLength = 0;
674  uc.nScheme = 0;
675  uc.lpszHostName = NULL;
676  uc.dwHostNameLength = ~0u;
677  uc.nPort = 0;
678  uc.lpszUserName = NULL;
679  uc.dwUserNameLength = ~0u;
680  uc.lpszPassword = NULL;
681  uc.dwPasswordLength = ~0u;
682  uc.lpszUrlPath = NULL;
683  uc.dwUrlPathLength = ~0u;
684  uc.lpszExtraInfo = NULL;
685  uc.dwExtraInfoLength = ~0u;
686  ret = WinHttpCrackUrl( url14, 0, 0, &uc );
687  ok( ret, "WinHttpCrackUrl failed le=%u\n", GetLastError() );
688  ok( !uc.lpszScheme, "unexpected scheme %s\n", wine_dbgstr_w(uc.lpszScheme) );
689  ok( !uc.dwSchemeLength, "unexpected length %u\n", uc.dwSchemeLength );
690  ok( uc.nScheme == INTERNET_SCHEME_HTTP, "unexpected scheme %u\n", uc.nScheme );
691  ok( !lstrcmpW( uc.lpszHostName, url14 + 7 ), "unexpected hostname %s\n", wine_dbgstr_w(uc.lpszHostName) );
692  ok( uc.dwHostNameLength == 14, "unexpected length %u\n", uc.dwHostNameLength );
693  ok( uc.nPort == 80, "unexpected port %u\n", uc.nPort );
694  ok( !uc.lpszUserName, "unexpected username\n" );
695  ok( !uc.dwUserNameLength, "unexpected length %u\n", uc.dwUserNameLength );
696  ok( !uc.lpszPassword, "unexpected password\n" );
697  ok( !uc.dwPasswordLength, "unexpected length %u\n", uc.dwPasswordLength );
698  ok( !lstrcmpW( uc.lpszUrlPath, url14 + 21 ), "unexpected path %s\n", wine_dbgstr_w(uc.lpszUrlPath) );
699  ok( uc.dwUrlPathLength == 5, "unexpected length %u\n", uc.dwUrlPathLength );
700  ok( !uc.lpszExtraInfo[0], "unexpected extra info %s\n", wine_dbgstr_w(uc.lpszExtraInfo) );
701  ok( uc.dwExtraInfoLength == 0, "unexpected length %u\n", uc.dwExtraInfoLength );
702 
703  uc.dwStructSize = sizeof(uc);
704  uc.lpszScheme = scheme;
705  uc.dwSchemeLength = 0;
706  uc.nScheme = 0;
707  uc.lpszHostName = NULL;
708  uc.dwHostNameLength = 0;
709  uc.nPort = 0;
710  uc.lpszUserName = NULL;
711  uc.dwUserNameLength = ~0u;
712  uc.lpszPassword = NULL;
713  uc.dwPasswordLength = ~0u;
714  uc.lpszUrlPath = NULL;
715  uc.dwUrlPathLength = 0;
716  uc.lpszExtraInfo = NULL;
717  uc.dwExtraInfoLength = 0;
718  SetLastError( 0xdeadbeef );
719  ret = WinHttpCrackUrl( url14, 0, 0, &uc );
720  error = GetLastError();
721  ok( !ret, "WinHttpCrackUrl succeeded\n" );
722  ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
723  ok( !lstrcmpW( uc.lpszScheme, http ), "unexpected scheme %s\n", wine_dbgstr_w(uc.lpszScheme) );
724  ok( !uc.dwSchemeLength, "unexpected length %u\n", uc.dwSchemeLength );
725  ok( uc.nScheme == 0, "unexpected scheme %u\n", uc.nScheme );
726  ok( !uc.lpszHostName, "unexpected hostname %s\n", wine_dbgstr_w(uc.lpszHostName) );
727  ok( uc.dwHostNameLength == 0, "unexpected length %u\n", uc.dwHostNameLength );
728  ok( uc.nPort == 0, "unexpected port %u\n", uc.nPort );
729  ok( !uc.lpszUserName, "unexpected username\n" );
730  ok( uc.dwUserNameLength == ~0u, "unexpected length %u\n", uc.dwUserNameLength );
731  ok( !uc.lpszPassword, "unexpected password\n" );
732  ok( uc.dwPasswordLength == ~0u, "unexpected length %u\n", uc.dwPasswordLength );
733  ok( !uc.lpszUrlPath, "unexpected path %s\n", wine_dbgstr_w(uc.lpszUrlPath) );
734  ok( uc.dwUrlPathLength == 0, "unexpected length %u\n", uc.dwUrlPathLength );
735  ok( !uc.lpszExtraInfo, "unexpected extra info %s\n", wine_dbgstr_w(uc.lpszExtraInfo) );
736  ok( uc.dwExtraInfoLength == 0, "unexpected length %u\n", uc.dwExtraInfoLength );
737 
738  reset_url_components( &uc );
739  SetLastError( 0xdeadbeef );
740  ret = WinHttpCrackUrl( url15, 0, 0, &uc );
741  error = GetLastError();
742  ok( !ret, "WinHttpCrackUrl succeeded\n" );
743  ok( error == ERROR_WINHTTP_INVALID_URL, "got %u\n", error );
744 
745  reset_url_components( &uc );
746  uc.nPort = 1;
747  ret = WinHttpCrackUrl( url16, 0, 0, &uc );
748  ok( ret, "got %u\n", GetLastError() );
749  ok( !uc.nPort, "got %u\n", uc.nPort );
750 
751  reset_url_components( &uc );
752  uc.nPort = 1;
753  ret = WinHttpCrackUrl( url17, 0, 0, &uc );
754  ok( ret, "got %u\n", GetLastError() );
755  todo_wine ok( uc.nPort == 80, "got %u\n", uc.nPort );
756 }
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
static const WCHAR url8[]
Definition: url.c:56
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define ERROR_SUCCESS
Definition: deptool.c:10
DWORD ret
Definition: url.c:448
#define error(str)
Definition: mkdosfs.c:1605
DWORD dwStructSize
Definition: wininet.h:211
static const WCHAR url17[]
Definition: url.c:74
int WINAPI lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:170
char * host
Definition: whois.c:55
#define wine_dbgstr_w
Definition: kernel32.h:34
DWORD scheme
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
static const WCHAR url12[]
Definition: url.c:67
DWORD dwUserNameLength
Definition: wininet.h:219
static const WCHAR url_k6[]
Definition: url.c:87
LPWSTR lpszHostName
Definition: wininet.h:215
static const WCHAR url15[]
Definition: url.c:72
LPWSTR lpszExtraInfo
Definition: wininet.h:224
static const WCHAR url_k4[]
Definition: url.c:83
static const WCHAR url_k5[]
Definition: url.c:85
static const WCHAR url9[]
Definition: url.c:59
pass
Definition: typegen.h:24
static WCHAR password[]
Definition: url.c:33
DWORD dwSchemeLength
Definition: wininet.h:213
static const WCHAR url_k7[]
Definition: url.c:89
INTERNET_PORT nPort
Definition: wininet.h:217
unsigned int BOOL
Definition: ntddk_ex.h:94
static const WCHAR url11[]
Definition: url.c:65
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
static const WCHAR url16[]
Definition: url.c:73
static WCHAR username[]
Definition: url.c:32
BOOL WINAPI WinHttpCrackUrl(LPCWSTR url, DWORD len, DWORD flags, LPURL_COMPONENTSW uc)
Definition: url.c:183
#define ICU_ESCAPE
Definition: winhttp.h:48
static const WCHAR url10[]
Definition: url.c:62
static const WCHAR url_k3[]
Definition: url.c:81
static const WCHAR url_k8[]
Definition: url.c:91
Definition: id3.c:18
LPWSTR lpszScheme
Definition: wininet.h:212
__wchar_t WCHAR
Definition: xmlstorage.h:180
static const WCHAR url6[]
Definition: url.c:48
#define ERROR_WINHTTP_INVALID_URL
Definition: winhttp.h:191
INTERNET_SCHEME nScheme
Definition: wininet.h:214
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR url_k9[]
Definition: url.c:93
#define SetLastError(x)
Definition: compat.h:409
static const WCHAR url14[]
Definition: url.c:71
static const WCHAR url7[]
Definition: url.c:51
#define ERROR_WINHTTP_UNRECOGNIZED_SCHEME
Definition: winhttp.h:192
DWORD dwPasswordLength
Definition: wininet.h:221
DWORD dwHostNameLength
Definition: wininet.h:216
static const WCHAR url4[]
Definition: url.c:44
static const WCHAR url13[]
Definition: url.c:69
LPWSTR lpszUserName
Definition: wininet.h:218
#define todo_wine
Definition: test.h:154
LPWSTR lpszUrlPath
Definition: wininet.h:222
#define broken(x)
Definition: _sntprintf.h:21
static const WCHAR url_k2[]
Definition: url.c:79
static WCHAR http[]
Definition: url.c:30
DWORD dwUrlPathLength
Definition: wininet.h:223
static const WCHAR url1[]
Definition: url.c:38
static void reset_url_components(URL_COMPONENTS *uc)
Definition: url.c:322
Definition: services.c:325
static WCHAR empty[]
Definition: url.c:28
static WCHAR winehq[]
Definition: url.c:31
static WCHAR escape[]
Definition: url.c:36
#define ICU_DECODE
Definition: winhttp.h:291
static WCHAR about[]
Definition: url.c:34
static const WCHAR url_k1[]
Definition: url.c:76
const char * path
Definition: url.c:446
void user(int argc, const char *argv[])
Definition: cmds.c:1350
LPWSTR lpszPassword
Definition: wininet.h:220
static const WCHAR url_k10[]
Definition: url.c:95
DWORD dwExtraInfoLength
Definition: wininet.h:225
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by START_TEST().

◆ WinHttpCreateUrl_test()

static void WinHttpCreateUrl_test ( void  )
static

Definition at line 117 of file url.c.

118 {
119  URL_COMPONENTS uc;
120  WCHAR *url;
121  DWORD len, err;
122  BOOL ret;
123 
124  /* NULL components */
125  len = ~0u;
126  SetLastError( 0xdeadbeef );
127  ret = WinHttpCreateUrl( NULL, 0, NULL, &len );
128  ok( !ret, "expected failure\n" );
129  ok( GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER got %u\n", GetLastError() );
130  ok( len == ~0u, "expected len ~0u got %u\n", len );
131 
132  /* zero'ed components */
133  memset( &uc, 0, sizeof(URL_COMPONENTS) );
134  SetLastError( 0xdeadbeef );
135  ret = WinHttpCreateUrl( &uc, 0, NULL, &len );
136  ok( !ret, "expected failure\n" );
137  ok( GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER got %u\n", GetLastError() );
138  ok( len == ~0u, "expected len ~0u got %u\n", len );
139 
140  /* valid components, NULL url, NULL length */
141  fill_url_components( &uc );
142  SetLastError( 0xdeadbeef );
143  ret = WinHttpCreateUrl( &uc, 0, NULL, NULL );
144  ok( !ret, "expected failure\n" );
145  ok( GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER got %u\n", GetLastError() );
146 
147  /* valid components, NULL url, insufficient length */
148  len = 0;
149  SetLastError( 0xdeadbeef );
150  ret = WinHttpCreateUrl( &uc, 0, NULL, &len );
151  ok( !ret, "expected failure\n" );
152  ok( GetLastError() == ERROR_INSUFFICIENT_BUFFER, "expected ERROR_INSUFFICIENT_BUFFER got %u\n", GetLastError() );
153  ok( len == 57, "expected len 57 got %u\n", len );
154 
155  /* valid components, NULL url, sufficient length */
156  SetLastError( 0xdeadbeef );
157  len = 256;
158  ret = WinHttpCreateUrl( &uc, 0, NULL, &len );
159  err = GetLastError();
160  ok( !ret, "expected failure\n" );
162  "expected ERROR_INVALID_PARAMETER got %u\n", GetLastError() );
163  ok( len == 256 || broken(len == 57) /* < win7 */, "expected len 256 got %u\n", len );
164 
165  /* correct size, NULL url */
166  fill_url_components( &uc );
167  SetLastError( 0xdeadbeef );
168  ret = WinHttpCreateUrl( &uc, 0, NULL, &len );
169  err = GetLastError();
170  ok( !ret, "expected failure\n" );
172  "expected ERROR_INVALID_PARAMETER got %u\n", GetLastError() );
173  ok( len == 256 || broken(len == 57) /* < win7 */, "expected len 256 got %u\n", len );
174 
175  /* valid components, allocated url, short length */
176  SetLastError( 0xdeadbeef );
177  url = HeapAlloc( GetProcessHeap(), 0, 256 * sizeof(WCHAR) );
178  url[0] = 0;
179  len = 2;
180  ret = WinHttpCreateUrl( &uc, 0, url, &len );
181  ok( !ret, "expected failure\n" );
182  ok( GetLastError() == ERROR_INSUFFICIENT_BUFFER, "expected ERROR_INSUFFICIENT_BUFFER got %u\n", GetLastError() );
183  ok( len == 57, "expected len 57 got %u\n", len );
184 
185  /* allocated url, NULL scheme */
186  SetLastError( 0xdeadbeef );
187  uc.lpszScheme = NULL;
188  url[0] = 0;
189  len = 256;
190  ret = WinHttpCreateUrl( &uc, 0, url, &len );
191  ok( ret, "expected success\n" );
192  ok( GetLastError() == ERROR_SUCCESS || broken(GetLastError() == 0xdeadbeef) /* < win7 */,
193  "expected ERROR_SUCCESS got %u\n", GetLastError() );
194  ok( len == 56, "expected len 56 got %u\n", len );
195  ok( !lstrcmpW( url, url1 ), "url doesn't match\n" );
196 
197  /* allocated url, 0 scheme */
198  fill_url_components( &uc );
199  uc.nScheme = 0;
200  url[0] = 0;
201  len = 256;
202  ret = WinHttpCreateUrl( &uc, 0, url, &len );
203  ok( ret, "expected success\n" );
204  ok( len == 56, "expected len 56 got %u\n", len );
205 
206  /* valid components, allocated url */
207  fill_url_components( &uc );
208  url[0] = 0;
209  len = 256;
210  ret = WinHttpCreateUrl( &uc, 0, url, &len );
211  ok( ret, "expected success\n" );
212  ok( len == 56, "expected len 56 got %d\n", len );
213  ok( !lstrcmpW( url, url1 ), "url doesn't match\n" );
214 
215  /* valid username, NULL password */
216  fill_url_components( &uc );
217  uc.lpszPassword = NULL;
218  url[0] = 0;
219  len = 256;
220  ret = WinHttpCreateUrl( &uc, 0, url, &len );
221  ok( ret, "expected success\n" );
222 
223  /* valid username, empty password */
224  fill_url_components( &uc );
225  uc.lpszPassword = empty;
226  url[0] = 0;
227  len = 256;
228  ret = WinHttpCreateUrl( &uc, 0, url, &len );
229  ok( ret, "expected success\n" );
230  ok( len == 56, "expected len 56 got %u\n", len );
231  ok( !lstrcmpW( url, url2 ), "url doesn't match\n" );
232 
233  /* valid password, NULL username */
234  fill_url_components( &uc );
235  SetLastError( 0xdeadbeef );
236  uc.lpszUserName = NULL;
237  url[0] = 0;
238  len = 256;
239  ret = WinHttpCreateUrl( &uc, 0, url, &len );
240  ok( !ret, "expected failure\n" );
241  ok( GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER got %u\n", GetLastError() );
242 
243  /* valid password, empty username */
244  fill_url_components( &uc );
245  uc.lpszUserName = empty;
246  url[0] = 0;
247  len = 256;
248  ret = WinHttpCreateUrl( &uc, 0, url, &len );
249  ok( ret, "expected success\n");
250 
251  /* NULL username, NULL password */
252  fill_url_components( &uc );
253  uc.lpszUserName = NULL;
254  uc.lpszPassword = NULL;
255  url[0] = 0;
256  len = 256;
257  ret = WinHttpCreateUrl( &uc, 0, url, &len );
258  ok( ret, "expected success\n" );
259  ok( len == 38, "expected len 38 got %u\n", len );
260  ok( !lstrcmpW( url, url3 ), "url doesn't match\n" );
261 
262  /* empty username, empty password */
263  fill_url_components( &uc );
264  uc.lpszUserName = empty;
265  uc.lpszPassword = empty;
266  url[0] = 0;
267  len = 256;
268  ret = WinHttpCreateUrl( &uc, 0, url, &len );
269  ok( ret, "expected success\n" );
270  ok( len == 56, "expected len 56 got %u\n", len );
271  ok( !lstrcmpW( url, url4 ), "url doesn't match\n" );
272 
273  /* nScheme has lower precedence than lpszScheme */
274  fill_url_components( &uc );
275  uc.lpszScheme = ftp;
277  url[0] = 0;
278  len = 256;
279  ret = WinHttpCreateUrl( &uc, 0, url, &len );
280  ok( ret, "expected success\n" );
281  ok( len == lstrlenW( url5 ), "expected len %d got %u\n", lstrlenW( url5 ) + 1, len );
282  ok( !lstrcmpW( url, url5 ), "url doesn't match\n" );
283 
284  /* non-standard port */
285  uc.lpszScheme = http;
287  uc.nPort = 42;
288  url[0] = 0;
289  len = 256;
290  ret = WinHttpCreateUrl( &uc, 0, url, &len );
291  ok( ret, "expected success\n" );
292  ok( len == 59, "expected len 59 got %u\n", len );
293  ok( !lstrcmpW( url, url6 ), "url doesn't match\n" );
294 
295  /* escape extra info */
296  fill_url_components( &uc );
297  uc.lpszExtraInfo = escape;
299  url[0] = 0;
300  len = 256;
301  ret = WinHttpCreateUrl( &uc, ICU_ESCAPE, url, &len );
302  ok( ret, "expected success\n" );
303  ok( len == 113, "expected len 113 got %u\n", len );
304  ok( !lstrcmpW( url, url7 ), "url doesn't match\n" );
305 
306  /* NULL lpszScheme, 0 nScheme and nPort */
307  fill_url_components( &uc );
308  uc.lpszScheme = NULL;
309  uc.dwSchemeLength = 0;
310  uc.nScheme = 0;
311  uc.nPort = 0;
312  url[0] = 0;
313  len = 256;
314  ret = WinHttpCreateUrl( &uc, 0, url, &len );
315  ok( ret, "expected success\n" );
316  ok( len == 58, "expected len 58 got %u\n", len );
317  ok( !lstrcmpW( url, url8 ), "url doesn't match\n" );
318 
319  HeapFree( GetProcessHeap(), 0, url );
320 }
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
LPWSTR lpszExtraInfo
Definition: winhttp.h:478
static const WCHAR url8[]
Definition: url.c:56
#define ERROR_SUCCESS
Definition: deptool.c:10
DWORD ret
Definition: url.c:448
static const WCHAR url3[]
Definition: url.c:42
int WINAPI lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:170
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
static const WCHAR url5[]
Definition: url.c:45
#define lstrlenW
Definition: compat.h:407
static void fill_url_components(URL_COMPONENTS *uc)
Definition: url.c:98
DWORD dwSchemeLength
Definition: winhttp.h:467
static const WCHAR url2[]
Definition: url.c:41
unsigned int BOOL
Definition: ntddk_ex.h:94
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
INTERNET_SCHEME nScheme
Definition: winhttp.h:468
#define ICU_ESCAPE
Definition: winhttp.h:48
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
DWORD dwExtraInfoLength
Definition: winhttp.h:479
__wchar_t WCHAR
Definition: xmlstorage.h:180
static const WCHAR url6[]
Definition: url.c:48
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
static const WCHAR url7[]
Definition: url.c:51
static const WCHAR url4[]
Definition: url.c:44
const char * url
Definition: url.c:447
INTERNET_PORT nPort
Definition: winhttp.h:471
GLenum GLsizei len
Definition: glext.h:6722
#define err(...)
LPWSTR lpszUserName
Definition: winhttp.h:472
#define broken(x)
Definition: _sntprintf.h:21
static WCHAR http[]
Definition: url.c:30
static const WCHAR url1[]
Definition: url.c:38
BOOL WINAPI WinHttpCreateUrl(LPURL_COMPONENTS uc, DWORD flags, LPWSTR url, LPDWORD required)
Definition: url.c:416
LPWSTR lpszPassword
Definition: winhttp.h:474
static WCHAR empty[]
Definition: url.c:28
static WCHAR escape[]
Definition: url.c:36
#define memset(x, y, z)
Definition: compat.h:39
#define HeapFree(x, y, z)
Definition: compat.h:394
LPWSTR lpszScheme
Definition: winhttp.h:466
static WCHAR ftp[]
Definition: url.c:29
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by START_TEST().

Variable Documentation

◆ about

WCHAR about[] = {'/','s','i','t','e','/','a','b','o','u','t',0}
static

Definition at line 34 of file url.c.

Referenced by fill_url_components(), and WinHttpCrackUrl_test().

◆ empty

WCHAR empty[] = {0}
static

◆ escape

WCHAR escape[] = {' ','!','"','#','$','%','&','\'','(',')','*','+',',','-','.','/',':',';','<','=','>','?','@','[','\\',']','^','_','`','{','|','}','~',0}
static

◆ ftp

WCHAR ftp[] = {'f','t','p',0}
static

Definition at line 29 of file url.c.

Referenced by FTPInitLibrary(), and WinHttpCreateUrl_test().

◆ http

◆ password

WCHAR password[] = {'p','a','s','s','w','o','r','d',0}
static

Definition at line 33 of file url.c.

Referenced by fill_url_components(), and WinHttpCrackUrl_test().

◆ query

WCHAR query[] = {'?','q','u','e','r','y',0}
static

Definition at line 35 of file url.c.

Referenced by fill_url_components().

◆ url1

const WCHAR url1[]
static
Initial value:
=
{'h','t','t','p',':','/','/','u','s','e','r','n','a','m','e',':','p','a','s','s','w','o','r','d',
'@','w','w','w','.','w','i','n','e','h','q','.','o','r','g','/','s','i','t','e','/','a','b','o','u','t','?','q','u','e','r','y',0}

Definition at line 38 of file url.c.

Referenced by test_CreateURLMoniker(), test_UrlCombine(), WinHttpCrackUrl_test(), and WinHttpCreateUrl_test().

◆ url10

const WCHAR url10[]
static
Initial value:
=
{'h','t','t','p','s',':','/','/','u','s','e','r','n','a','m','e',':','p','a','s','s','w','o','r','d',
'@','w','w','w','.','w','i','n','e','h','q','.','o','r','g',':','4','4','3','/','s','i','t','e','/','a','b','o','u','t','?','q','u','e','r','y',0}

Definition at line 62 of file url.c.

Referenced by WinHttpCrackUrl_test().

◆ url11

const WCHAR url11[]
static
Initial value:
=
{'h','t','t','p',':','/','/','e','x','a','m','p','l','e','.','n','e','t','/','p','a','t','h','?','v','a','r','1','=','e','x','a','m','p','l','e','@','e','x','a','m','p','l','e','.','c','o','m','&','v','a','r','2','=','x','&','v','a','r','3','=','y', 0}

Definition at line 65 of file url.c.

Referenced by WinHttpCrackUrl_test().

◆ url12

const WCHAR url12[]
static
Initial value:
=
{'h','t','t','p','s',':','/','/','t','o','o','l','s','.','g','o','o','g','l','e','.','c','o','m','/','s','e','r','v','i','c','e','/','u','p','d','a','t','e','2','?','w','=','3',':','B','x','D','H','o','W','y','8','e','z','M',0}

Definition at line 67 of file url.c.

Referenced by WinHttpCrackUrl_test().

◆ url13

const WCHAR url13[]
static
Initial value:
=
{'h','t','t','p',':','/','/','w','i','n','e','h','q','.','o',' ','g','/','p','a','t','h',' ','w','i','t','h',' ','s','p','a','c','e','s',0}

Definition at line 69 of file url.c.

Referenced by WinHttpCrackUrl_test().

◆ url14

const WCHAR url14[] = {'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q','.','o','r','g','/','t','e','s','t',0}
static

Definition at line 71 of file url.c.

Referenced by WinHttpCrackUrl_test().

◆ url15

const WCHAR url15[] = {'h','t','t','p',':','/','/','w','i','n','e','h','q','.','o','r','g',':','6','5','5','3','6',0}
static

Definition at line 72 of file url.c.

Referenced by WinHttpCrackUrl_test().

◆ url16

const WCHAR url16[] = {'h','t','t','p',':','/','/','w','i','n','e','h','q','.','o','r','g',':','0',0}
static

Definition at line 73 of file url.c.

Referenced by WinHttpCrackUrl_test().

◆ url17

const WCHAR url17[] = {'h','t','t','p',':','/','/','w','i','n','e','h','q','.','o','r','g',':',0}
static

Definition at line 74 of file url.c.

Referenced by WinHttpCrackUrl_test().

◆ url2

const WCHAR url2[] = {'h','t','t','p',':','/','/','u','s','e','r','n','a','m','e',':',0}
static

◆ url3

const WCHAR url3[]
static
Initial value:
=
{'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q','.','o','r','g','/','s','i','t','e','/','a','b','o','u','t','?','q','u','e','r','y',0}

Definition at line 42 of file url.c.

Referenced by InternetCrackUrlW_test(), and WinHttpCreateUrl_test().

◆ url4

const WCHAR url4[] = {'h','t','t','p',':','/','/',0}
static

Definition at line 44 of file url.c.

Referenced by WinHttpCrackUrl_test(), and WinHttpCreateUrl_test().

◆ url5

const WCHAR url5[]
static
Initial value:
=
{'f','t','p',':','/','/','u','s','e','r','n','a','m','e',':','p','a','s','s','w','o','r','d',
'@','w','w','w','.','w','i','n','e','h','q','.','o','r','g',':','8','0','/','s','i','t','e','/','a','b','o','u','t','?','q','u','e','r','y',0}

Definition at line 45 of file url.c.

Referenced by WinHttpCreateUrl_test().

◆ url6

const WCHAR url6[]
static
Initial value:
=
{'h','t','t','p',':','/','/','u','s','e','r','n','a','m','e',':','p','a','s','s','w','o','r','d',
'@','w','w','w','.','w','i','n','e','h','q','.','o','r','g',':','4','2','/','s','i','t','e','/','a','b','o','u','t','?','q','u','e','r','y',0}

Definition at line 48 of file url.c.

Referenced by WinHttpCrackUrl_test(), and WinHttpCreateUrl_test().

◆ url7

const WCHAR url7[]
static
Initial value:
=
{'h','t','t','p',':','/','/','u','s','e','r','n','a','m','e',':','p','a','s','s','w','o','r','d',
'@','w','w','w','.','w','i','n','e','h','q','.','o','r','g','/','s','i','t','e','/','a','b','o','u','t',
'%','2','0','!','%','2','2','%','2','3','$','%','2','5','&','\'','(',')','*','+',',','-','.','/',':',';','%','3','C','=','%','3','E','?','@','%',
'5','B','%','5','C','%','5','D','%','5','E','_','%','6','0','%','7','B','%','7','C','%','7','D','%','7','E',0}

Definition at line 51 of file url.c.

Referenced by WinHttpCrackUrl_test(), and WinHttpCreateUrl_test().

◆ url8

const WCHAR url8[]
static
Initial value:
=
{'h','t','t','p',':','/','/','u','s','e','r','n','a','m','e',':','p','a','s','s','w','o','r','d',
'@','w','w','w','.','w','i','n','e','h','q','.','o','r','g',':','0','/','s','i','t','e','/','a','b','o','u','t','?','q','u','e','r','y',0}

Definition at line 56 of file url.c.

Referenced by WinHttpCrackUrl_test(), and WinHttpCreateUrl_test().

◆ url9

const WCHAR url9[]
static
Initial value:
=
{'h','t','t','p',':','/','/','u','s','e','r','n','a','m','e',':','p','a','s','s','w','o','r','d',
'@','w','w','w','.','w','i','n','e','h','q','.','o','r','g',':','8','0','/','s','i','t','e','/','a','b','o','u','t','?','q','u','e','r','y',0}

Definition at line 59 of file url.c.

Referenced by WinHttpCrackUrl_test().

◆ url_k1

const WCHAR url_k1[]
static
Initial value:
=
{'h','t','t','p',':','/','/','u','s','e','r','n','a','m','e',':','p','a','s','s','w','o','r','d',
'@','w','w','w','.','w','i','n','e','h','q','.','o','r','g','/','s','i','t','e','/','a','b','o','u','t',0}

Definition at line 76 of file url.c.

Referenced by WinHttpCrackUrl_test().

◆ url_k10

const WCHAR url_k10[]
static
Initial value:
=
{'h','t','t','p',':','/','/','w','i','n','e','h','q','/','p','o','s','t',';','a',0}

Definition at line 95 of file url.c.

Referenced by WinHttpCrackUrl_test().

◆ url_k2

const WCHAR url_k2[]
static
Initial value:
=
{'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q','.','o','r','g',0}

Definition at line 79 of file url.c.

Referenced by WinHttpCrackUrl_test().

◆ url_k3

const WCHAR url_k3[]
static
Initial value:
=
{'h','t','t','p','s',':','/','/','w','w','w','.','w','i','n','e','h','q','.','o','r','g','/','p','o','s','t','?',0}

Definition at line 81 of file url.c.

Referenced by WinHttpCrackUrl_test().

◆ url_k4

const WCHAR url_k4[]
static
Initial value:
=
{'H','T','T','P',':','w','w','w','.','w','i','n','e','h','q','.','o','r','g',0}

Definition at line 83 of file url.c.

Referenced by WinHttpCrackUrl_test().

◆ url_k5

const WCHAR url_k5[]
static
Initial value:
=
{'h','t','t','p',':','/','w','w','w','.','w','i','n','e','h','q','.','o','r','g',0}

Definition at line 85 of file url.c.

Referenced by WinHttpCrackUrl_test().

◆ url_k6

const WCHAR url_k6[]
static
Initial value:
=
{'w','w','w','.','w','i','n','e','h','q','.','o','r','g',0}

Definition at line 87 of file url.c.

Referenced by WinHttpCrackUrl_test().

◆ url_k7

const WCHAR url_k7[]
static
Initial value:
=
{'w','w','w',0}

Definition at line 89 of file url.c.

Referenced by WinHttpCrackUrl_test().

◆ url_k8

const WCHAR url_k8[]
static
Initial value:
=
{'h','t','t','p',0}

Definition at line 91 of file url.c.

Referenced by WinHttpCrackUrl_test().

◆ url_k9

const WCHAR url_k9[]
static
Initial value:
=
{'h','t','t','p',':','/','/','w','i','n','e','h','q','?',0}

Definition at line 93 of file url.c.

Referenced by WinHttpCrackUrl_test().

◆ username

WCHAR username[] = {'u','s','e','r','n','a','m','e',0}
static

Definition at line 32 of file url.c.

Referenced by _build_action_map(), _set_action_map(), canonicalize_username(), CredPackAuthenticationBufferW(), CredUnPackAuthenticationBufferW(), do_authorization(), fill_url_components(), find_existing_credential(), get_mapping_key(), InternetCreateUrlA_test(), iso_connect(), iso_send_connection_request(), load_mapping_settings(), map_user_to_ids(), mcs_connect_start(), NetFileEnum(), NetGroupAddUser(), NetGroupDelUser(), NetSessionDel(), NetSessionEnum(), NetSessionGetInfo(), NetUserChangePassword(), NetUserDel(), NetUserGetGroups(), NetUserGetInfo(), NetUserGetLocalGroups(), NetUserSetGroups(), NetUserSetInfo(), nfs41_client_owner(), nfs41_idmap_name_to_ids(), ntlm_InitializeSecurityContextW(), POP3Transport_CommandUSER(), process_redirect_pdu(), rdp_connect(), rdp_reconnect(), sec_connect(), set_credentials(), set_installer_properties(), set_request_credentials(), should_enumerate_device(), SspiPromptForCredentialsW(), test_create_delete_svc(), test_CredMarshalCredentialA(), test_CredUIPromptForCredentials(), test_CredUnmarshalCredentialA(), test_HlinkCreateExtensionServices(), test_IWinHttpRequest(), test_MsiSourceListAddSource(), test_proxy_direct(), test_RpcServerInqDefaultPrincName(), test_SspiEncodeStringsAsAuthIdentity(), test_SspiPrepareForCredWrite(), test_SspiPromptForCredentials(), test_Win32_ComputerSystem(), username_cmp(), winhttp_request_SetCredentials(), WinHttpCrackUrl_test(), WinHttpSetCredentials(), WININET_PasswordDialog(), WININET_ProxyPasswordDialog(), WININET_SetAuthorization(), and WTSQuerySessionInformationW().

◆ winehq

WCHAR winehq[] = {'w','w','w','.','w','i','n','e','h','q','.','o','r','g',0}
static