Feature/eas query profile#3
Open
remdev wants to merge 2 commits into
Open
Conversation
Enable Exchange deployments that require plain MS-ASHTTP URI parameters and Outlook-style device headers without manual ExtraHeaders wiring.
There was a problem hiding this comment.
Pull request overview
Adds Outlook-like Exchange ActiveSync profile support by introducing configurable query encoding and first-class device profile metadata for headers and Provision payloads.
Changes:
- Adds
QueryEncodingselection with plain URI query support. - Adds device profile fields, headers, and Provision
DeviceInformation. - Updates README, spec coverage, and tests for query/profile behavior.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Documents Outlook-like profile configuration. |
| internal/spec/coverage.csv | Adds required spec rows for query/device profile behavior. |
| eas/provision.go | Adds Provision DeviceInformation WBXML structures. |
| client/request.go | Adds query encoding type and ordered plain query encoding. |
| client/request_extra_test.go | Extends plain query ordering assertions. |
| client/integration_test.go | Adds integration tests for plain queries and device headers. |
| client/headers.go | Adds device profile header application helper. |
| client/cmd_provision.go | Adds device information to Provision requests. |
| client/client.go | Adds config/client fields, defaults, validation, and query encoding selection. |
| client/client_profile_test.go | Adds Provision device information coverage. |
| client/client_extra_test.go | Adds unknown query encoding validation test. |
Comments suppressed due to low confidence (2)
client/client.go:190
- Defaulting the device-profile fields makes them present for every client, so
ApplyDeviceProfileHeaderswill emit Outlook/iOS/RU/Apple headers even when the caller did not opt into that profile. It also prevents existingExtraHeadersvalues for the same X-MS-Device* keys from being merged, becausemergeExtraHeadersskips keys already set by these defaults, which is a breaking change for the previously documented customization path.
if c.DeviceModel == "" {
c.DeviceModel = defaultDeviceModel
}
if c.DeviceOS == "" {
c.DeviceOS = "iOS 17.5"
}
if c.DeviceOSLanguage == "" {
c.DeviceOSLanguage = "ru"
}
if c.Carrier == "" {
c.Carrier = "Apple"
}
if c.DeviceUserAgent == "" {
c.DeviceUserAgent = "Outlook-iOS-Android/1.0"
README.md:107
- This recommends setting
Localefor a plain-query profile, butEncodePlaindoes not include the locale and the Config comment says plain queries useAccept-Languageinstead. As written, the README impliesLocale: 0x0419affects the plain request when it is actually ignored forQueryEncodingPlain.
Many servers key off the request query shape and Outlook-style device metadata. Use `QueryEncoding: client.QueryEncodingPlain` to send `Cmd=...&User=...&DeviceId=...&DeviceType=...`, `DeviceType: "Outlook"` when emulating Outlook, and `Locale: 0x0419` with `AcceptLanguage: "ru-RU"` for ru-RU. First-class device profile fields are sent as `X-MS-Device*` headers; keep `ExtraHeaders` for integration-specific headers that are not modeled directly. If you must avoid HTTP/2 to match an older appliance or proxy, pass `ForceHTTP11: true` with `HTTPClient: nil`; if you inject your own `HTTPClient`, tune its transport yourself (`ForceHTTP11` is ignored).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| MS-ASHTTP/client.profile.force-http11,MS-ASHTTP,§2.2.1,When HTTPClient is nil and ForceHTTP11 is true New configures a client transport cloned from DefaultTransport with TLSNextProto set to a non-nil empty map to disable HTTP/2,required | ||
| MS-ASHTTP/client.query-encoding,MS-ASHTTP,§2.2.1.1.1,Config.QueryEncoding selects base64 or plain text query encoding while defaulting to base64,required | ||
| MS-ASHTTP/client.profile.device-headers,MS-ASHTTP,§2.2.2,Config device profile fields emit X-MS-DeviceModel; X-MS-DeviceOS; X-MS-DeviceOSLanguage; X-MS-DeviceCarrier; X-MS-DevicePhoneNumber; X-MS-DeviceUserAgent when set,required | ||
| MS-ASCMD/status.165.device-information-required,MS-ASCMD,§2.2.4,Status 165 indicates the client must send DeviceInformation during Provision,required |
| ### Outlook-like client profile | ||
|
|
||
| Many servers key off `DeviceType` and `Locale` (LCID), and expect additional metadata via headers rather than MS-ASHTTP query fields. Use `DeviceType: "Outlook"` when emulating Outlook; set `Locale` to `0x0409` for en-US or `0x0419` for ru-RU. Device model, OS version, or other vendor-specific strings are not separate `Config` fields—supply them with `ExtraHeaders` so they merge after the mandatory headers without replacing `User-Agent`, `MS-ASProtocolVersion`, and other values the client sets. If you must avoid HTTP/2 to match an older appliance or proxy, pass `ForceHTTP11: true` with `HTTPClient: nil`; if you inject your own `HTTPClient`, tune its transport yourself (`ForceHTTP11` is ignored). | ||
| Many servers key off the request query shape and Outlook-style device metadata. Use `QueryEncoding: client.QueryEncodingPlain` to send `Cmd=...&User=...&DeviceId=...&DeviceType=...`, `DeviceType: "Outlook"` when emulating Outlook, and `Locale: 0x0419` with `AcceptLanguage: "ru-RU"` for ru-RU. First-class device profile fields are sent as `X-MS-Device*` headers; keep `ExtraHeaders` for integration-specific headers that are not modeled directly. If you must avoid HTTP/2 to match an older appliance or proxy, pass `ForceHTTP11: true` with `HTTPClient: nil`; if you inject your own `HTTPClient`, tune its transport yourself (`ForceHTTP11` is ignored). |
Comment on lines
+123
to
+126
| queryEncoding := cfg.QueryEncoding | ||
| if queryEncoding == "" { | ||
| queryEncoding = QueryEncodingBase64 | ||
| } |
Comment on lines
+99
to
+108
| // Device profile fields are sent as X-MS-Device* headers and in the | ||
| // Provision DeviceInformation body. | ||
| DeviceModel string | ||
| DeviceOS string | ||
| DeviceOSLanguage string | ||
| Carrier string | ||
| PhoneNumber string | ||
| DeviceUserAgent string | ||
| DeviceFriendlyName string | ||
| DeviceIMEI string |
Comment on lines
+69
to
+79
| req.DeviceInformation = &eas.DeviceInformation{ | ||
| Set: eas.DeviceInformationSet{ | ||
| Model: c.DeviceModel, | ||
| IMEI: c.DeviceIMEI, | ||
| FriendlyName: c.DeviceFriendlyName, | ||
| OS: c.DeviceOS, | ||
| OSLanguage: c.DeviceOSLanguage, | ||
| PhoneNumber: c.PhoneNumber, | ||
| UserAgent: c.DeviceUserAgent, | ||
| MobileOperator: c.Carrier, | ||
| }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.