Skip to content

Commit

Permalink
capricorn86#463@minor: Continue Fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mas0nShi committed Oct 16, 2022
1 parent d588d3b commit 3431208
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/happy-dom/src/xml-http-request/IXMLHttpRequest.ts
@@ -1,7 +1,7 @@
export interface IXMLHttpRequestOptions {
host: string;
port: number;
uri: string;
path: string;
method: string;
headers: object;
agent: boolean;
Expand Down
12 changes: 6 additions & 6 deletions packages/happy-dom/src/xml-http-request/XMLHttpRequest.ts
Expand Up @@ -156,7 +156,7 @@ export default class XMLHttpRequest extends XMLHttpRequestEventTarget {
throw new DOMException('Request method not allowed', DOMExceptionNameEnum.securityError);
}
// Check responseType.
if (upperMethod === 'GET' && !!this.responseType && this.responseType !== 'text') {
if (!async && !!this.responseType && this.responseType !== 'text') {
throw new DOMException(
`Failed to execute 'open' on 'XMLHttpRequest': Synchronous requests from a document must not set a response type.`,
DOMExceptionNameEnum.invalidAccessError
Expand Down Expand Up @@ -355,7 +355,7 @@ export default class XMLHttpRequest extends XMLHttpRequestEventTarget {
const options: IXMLHttpRequestOptions = {
host: host,
port: port,
uri: uri,
path: uri,
method: this._settings.method,
headers: Object.assign(this._getDefaultRequestHeaders(), this._requestHeaders),
agent: false,
Expand Down Expand Up @@ -565,7 +565,7 @@ export default class XMLHttpRequest extends XMLHttpRequestEventTarget {
this._sendSyncRequest(
Object.assign(options, {
host: redirectUrl.host,
uri: redirectUrl.pathname + (redirectUrl.search ?? ''),
path: redirectUrl.pathname + (redirectUrl.search ?? ''),
port: redirectUrl.port || (ssl ? 443 : 80),
method: this._response.statusCode === 303 ? 'GET' : this._settings.method
}),
Expand All @@ -584,7 +584,7 @@ export default class XMLHttpRequest extends XMLHttpRequestEventTarget {
* @param ssl
* @param data
*/
private _sendAsyncRequest(options: object, ssl: boolean, data?: string): void {
private _sendAsyncRequest(options: IXMLHttpRequestOptions, ssl: boolean, data?: string): void {
// Use the proper protocol
const sendRequest = ssl ? HTTPS.request : HTTP.request;

Expand Down Expand Up @@ -621,7 +621,7 @@ export default class XMLHttpRequest extends XMLHttpRequestEventTarget {
Object.assign(options, {
host: redirectUrl.hostname,
port: redirectUrl.port,
uri: redirectUrl.pathname + (redirectUrl.search ?? ''),
path: redirectUrl.pathname + (redirectUrl.search ?? ''),
method: this._response.statusCode === 303 ? 'GET' : this._settings.method
}),
ssl,
Expand Down Expand Up @@ -716,7 +716,7 @@ export default class XMLHttpRequest extends XMLHttpRequestEventTarget {
};

// Create the request
this._request = sendRequest(options, responseHandler).on('error', errorHandler);
this._request = sendRequest(<object>options, responseHandler).on('error', errorHandler);

// Node 0.4 and later won't accept empty data. Make sure it's needed.
if (data) {
Expand Down

0 comments on commit 3431208

Please sign in to comment.