---
title: "init(url:mimeType:expectedContentLength:textEncodingName:)"
framework: foundation
role: symbol
role_heading: Initializer
path: "foundation/urlresponse/init(url:mimetype:expectedcontentlength:textencodingname:)-4s2s1"
---

# init(url:mimeType:expectedContentLength:textEncodingName:)

Creates an initialized URLResponse object with the URL, MIME type, length, and text encoding set to given values.

## Declaration

```swift
init(url URL: URL, mimeType MIMEType: String?, expectedContentLength length: Int, textEncodingName name: String?)
```

## Parameters

- `URL`: The URL for the new object.
- `MIMEType`: The MIME type.
- `length`: The expected content length.This value should be –1 if the expected length is undetermined
- `name`: The text encoding name. This value may be nil.

## Return Value

Return Value The initialized URL response.

## Discussion

Discussion This is the designated initializer for URLResponse.

## See Also

### Related Documentation

- [init(url:statusCode:httpVersion:headerFields:)](foundation/httpurlresponse/init(url:statuscode:httpversion:headerfields:)-21j4x.md)
