Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
61ea74b4
Commit
61ea74b4
authored
Jun 24, 2020
by
Hans Leidekker
Committed by
Alexandre Julliard
Jun 24, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
winhttp: Implement WinHttpWebSocketClose.
Signed-off-by:
Hans Leidekker
<
hans@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
da0515c1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
100 additions
and
2 deletions
+100
-2
request.c
dlls/winhttp/request.c
+97
-2
winhttp_private.h
dlls/winhttp/winhttp_private.h
+3
-0
No files found.
dlls/winhttp/request.c
View file @
61ea74b4
...
...
@@ -3540,10 +3540,105 @@ DWORD WINAPI WinHttpWebSocketShutdown( HINTERNET hsocket, USHORT status, void *r
return
ret
;
}
static
DWORD
socket_close
(
struct
socket
*
socket
,
USHORT
status
,
const
void
*
reason
,
DWORD
len
,
BOOL
async
)
{
struct
netconn
*
netconn
=
socket
->
request
->
netconn
;
DWORD
ret
,
count
;
while
(
socket
->
read_size
)
/* drain any pending data */
{
char
buf
[
1024
];
if
((
ret
=
receive_bytes
(
netconn
,
buf
,
min
(
socket
->
read_size
,
sizeof
(
buf
)),
&
count
)))
goto
done
;
socket
->
read_size
-=
count
;
}
if
(
socket
->
state
<
SOCKET_STATE_SHUTDOWN
)
{
if
((
ret
=
send_frame
(
netconn
,
WINHTTP_WEB_SOCKET_CLOSE_BUFFER_TYPE
,
status
,
reason
,
len
,
TRUE
)))
goto
done
;
socket
->
state
=
SOCKET_STATE_SHUTDOWN
;
}
if
((
ret
=
receive_frame
(
netconn
,
&
count
,
&
socket
->
buf_type
)))
goto
done
;
if
(
socket
->
buf_type
!=
WINHTTP_WEB_SOCKET_CLOSE_BUFFER_TYPE
||
(
count
&&
count
>
sizeof
(
socket
->
reason
)))
{
ret
=
ERROR_WINHTTP_INVALID_SERVER_RESPONSE
;
goto
done
;
}
if
((
ret
=
receive_bytes
(
netconn
,
(
char
*
)
&
socket
->
status
,
sizeof
(
socket
->
status
),
&
count
)))
goto
done
;
if
(
count
!=
sizeof
(
socket
->
status
))
{
ret
=
ERROR_WINHTTP_INVALID_SERVER_RESPONSE
;
goto
done
;
}
socket
->
status
=
RtlUshortByteSwap
(
socket
->
status
);
ret
=
receive_bytes
(
netconn
,
socket
->
reason
,
sizeof
(
socket
->
reason
),
&
socket
->
reason_len
);
done:
if
(
async
)
{
if
(
!
ret
)
send_callback
(
&
socket
->
hdr
,
WINHTTP_CALLBACK_STATUS_CLOSE_COMPLETE
,
NULL
,
0
);
else
{
WINHTTP_WEB_SOCKET_ASYNC_RESULT
result
;
result
.
AsyncResult
.
dwResult
=
API_READ_DATA
;
/* FIXME */
result
.
AsyncResult
.
dwError
=
ret
;
result
.
Operation
=
WINHTTP_WEB_SOCKET_CLOSE_OPERATION
;
send_callback
(
&
socket
->
hdr
,
WINHTTP_CALLBACK_STATUS_REQUEST_ERROR
,
&
result
,
sizeof
(
result
)
);
}
}
if
(
!
ret
)
socket
->
state
=
SOCKET_STATE_CLOSED
;
return
ret
;
}
static
void
task_socket_close
(
struct
task_header
*
task
)
{
struct
socket
*
socket
=
(
struct
socket
*
)
task
->
object
;
struct
socket_shutdown
*
s
=
(
struct
socket_shutdown
*
)
task
;
socket_close
(
socket
,
s
->
status
,
s
->
reason
,
s
->
len
,
TRUE
);
}
DWORD
WINAPI
WinHttpWebSocketClose
(
HINTERNET
hsocket
,
USHORT
status
,
void
*
reason
,
DWORD
len
)
{
FIXME
(
"%p, %u, %p, %u
\n
"
,
hsocket
,
status
,
reason
,
len
);
return
ERROR_INVALID_PARAMETER
;
struct
socket
*
socket
;
DWORD
ret
;
TRACE
(
"%p, %u, %p, %u
\n
"
,
hsocket
,
status
,
reason
,
len
);
if
(
len
&&
!
reason
)
return
ERROR_INVALID_PARAMETER
;
if
(
!
(
socket
=
(
struct
socket
*
)
grab_object
(
hsocket
)))
return
ERROR_INVALID_HANDLE
;
if
(
socket
->
hdr
.
type
!=
WINHTTP_HANDLE_TYPE_SOCKET
)
{
release_object
(
&
socket
->
hdr
);
return
ERROR_WINHTTP_INCORRECT_HANDLE_TYPE
;
}
if
(
socket
->
state
>=
SOCKET_STATE_CLOSED
)
{
release_object
(
&
socket
->
hdr
);
return
ERROR_WINHTTP_INCORRECT_HANDLE_STATE
;
}
if
(
socket
->
request
->
connect
->
hdr
.
flags
&
WINHTTP_FLAG_ASYNC
)
{
struct
socket_shutdown
*
s
;
if
(
!
(
s
=
heap_alloc
(
sizeof
(
*
s
)
)))
return
FALSE
;
s
->
hdr
.
object
=
&
socket
->
hdr
;
s
->
hdr
.
proc
=
task_socket_close
;
s
->
status
=
status
;
s
->
reason
=
reason
;
s
->
len
=
len
;
addref_object
(
&
socket
->
hdr
);
ret
=
queue_task
(
&
socket
->
hdr
,
&
socket
->
recv_q
,
(
struct
task_header
*
)
s
);
}
else
ret
=
socket_close
(
socket
,
status
,
reason
,
len
,
FALSE
);
release_object
(
&
socket
->
hdr
);
return
ret
;
}
DWORD
WINAPI
WinHttpWebSocketQueryCloseStatus
(
HINTERNET
hsocket
,
USHORT
*
status
,
void
*
reason
,
DWORD
len
,
...
...
dlls/winhttp/winhttp_private.h
View file @
61ea74b4
...
...
@@ -230,6 +230,9 @@ struct socket
struct
queue
recv_q
;
WINHTTP_WEB_SOCKET_BUFFER_TYPE
buf_type
;
DWORD
read_size
;
USHORT
status
;
char
reason
[
128
];
DWORD
reason_len
;
};
struct
task_header
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment