<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>80362</bug_id>
          
          <creation_ts>2012-03-05 17:45:26 -0800</creation_ts>
          <short_desc>WebSocket: Client does not support 401 Unauthorized response.</short_desc>
          <delta_ts>2026-03-04 16:43:14 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>WebCore Misc.</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>REOPENED</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Martin Banky">Mythiclese</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>achristensen</cc>
    
    <cc>andrewchen5678</cc>
    
    <cc>ap</cc>
    
    <cc>becky</cc>
    
    <cc>bfulgham</cc>
    
    <cc>dbates</cc>
    
    <cc>dieter</cc>
    
    <cc>harris.max</cc>
    
    <cc>he</cc>
    
    <cc>heiko-bugs.webkit.org</cc>
    
    <cc>ian</cc>
    
    <cc>jaf</cc>
    
    <cc>james.x.anderson+bugzilla</cc>
    
    <cc>julian</cc>
    
    <cc>Kilian.Brachtendorf</cc>
    
    <cc>manian</cc>
    
    <cc>me</cc>
    
    <cc>oskarbjs</cc>
    
    <cc>ossy</cc>
    
    <cc>patrakov</cc>
    
    <cc>piota</cc>
    
    <cc>revanscript</cc>
    
    <cc>Ryan.Slominski</cc>
    
    <cc>svarunan</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>webkit</cc>
    
    <cc>wilander</cc>
    
    <cc>yutak</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>571280</commentid>
    <comment_count>0</comment_count>
    <who name="Martin Banky">Mythiclese</who>
    <bug_when>2012-03-05 17:45:26 -0800</bug_when>
    <thetext>When opening a WebSocket connection to a server that requires authentication, the connection errors out with &quot;Unexpected response code: 401&quot;. This works in Firefox 11 beta 5.

According to RFC6455, section 4.1., &quot;The request MAY include any other header fields, for example, cookies [RFC6265] and/or authentication-related header fields such as the |Authorization| header field [RFC2616], which are processed according to documents that define them.&quot;, also in section 4.1., &quot;If the status code received from the server is not 101, the client handles the response per HTTP [RFC2616] procedures. In particular, the client might perform authentication if it receives a 401 status code; the server might redirect the client using a 3xx status code (but clients are not required to follow them), etc.&quot;, and in section 4.2.2., &quot;2. The server can perform additional client authentication, for example, by returning a 401 status code with the corresponding |WWW-Authenticate| header field as described in [RFC2616].&quot;

OS: Arch Linux with latest updates.
Browser: Chromium Version 17.0.963.65 and 19.0.1061.0 (125018)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>573293</commentid>
    <comment_count>1</comment_count>
    <who name="Yuta Kitamura">yutak</who>
    <bug_when>2012-03-07 15:16:36 -0800</bug_when>
    <thetext>We should do this, but how to implement this does not sound obvious to me.

By the way, WebSocket API spec has the following sentence:

    http://www.w3.org/TR/websockets/

    When the user agent validates the server&apos;s response during the &quot;establish a 
    WebSocket connection&quot; algorithm, if the status code received from the server 
    is not 101 (e.g. it is a redirect), the user agent must fail the websocket 
    connection.

The wording &quot;not 101 (e.g. it is a redirect)&quot; is a bit vague and there can be two understandings:
(1) the user agent must not perform redirection but must handle the other non-101 HTTP codes as it does in HTTP.
(2) the user agent must fail the WebSocket connection if the status code is not 101.

(2) is against RFC6455 so I assume (1) is right. Hixie, what do you think?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1131880</commentid>
    <comment_count>2</comment_count>
    <who name="Oskar Börjesson">oskarbjs</who>
    <bug_when>2015-10-09 05:06:05 -0700</bug_when>
    <thetext>This is supported in Chrome since late 2014 https://code.google.com/p/chromium/issues/detail?id=123862

The following browsers support this:
 Chrome
 Firefox
 Internet Explorer
 Edge
 Yandex

The following does not:
 Safari

Is this on anyone&apos;s agenda?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1152496</commentid>
    <comment_count>3</comment_count>
    <who name="Max Harris">harris.max</who>
    <bug_when>2016-01-04 13:34:46 -0800</bug_when>
    <thetext>This bug is causing me pain. Will this ever be fixed?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1300719</commentid>
    <comment_count>4</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2017-04-24 16:45:44 -0700</bug_when>
    <thetext>&lt;rdar://problem/31800452&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1326985</commentid>
    <comment_count>5</comment_count>
    <who name="Ryan Slominski">Ryan.Slominski</who>
    <bug_when>2017-07-10 06:39:21 -0700</bug_when>
    <thetext>Just to clarify, this bug is reporting that HTTP Basic Authentication does not work in Safari over WebSockets, correct?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1332299</commentid>
    <comment_count>6</comment_count>
    <who name="Varunan">svarunan</who>
    <bug_when>2017-07-26 02:13:16 -0700</bug_when>
    <thetext>@Ryan Slominski, I even have the same issue, Basic auth over websocket is not working in current Safari. Same works in other browsers. I thought of creating a new ticket, but just landed here.

In Safari
Basic auth over pure http works fine. But over websocket its not.

My Plan is to send user/password combo directly in websocket URL
`new WebSocket(&quot;ws://username:password@example.com&quot;)`, Once i receive http request with &quot;Authorization&quot; header validate it and upgrade to websockets in sockets server. But 

This way http -&gt; websocket upgrade happens only on auth validation.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1332340</commentid>
    <comment_count>7</comment_count>
    <who name="Alex Christensen">achristensen</who>
    <bug_when>2017-07-26 08:07:00 -0700</bug_when>
    <thetext>A workaround for now would be to send a fetch request or xhr with credentials before the first websocket.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1332953</commentid>
    <comment_count>8</comment_count>
    <who name="Varunan">svarunan</who>
    <bug_when>2017-07-28 06:40:05 -0700</bug_when>
    <thetext>Alex,
Its a client side code so anyone can bypass XHR request with credentials and directly connect to websocket URL which is visible.

It should a single http request (hand shake) with Authorisation header added and upgrade to websocket on auth success.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1393501</commentid>
    <comment_count>9</comment_count>
    <who name="">Kilian.Brachtendorf</who>
    <bug_when>2018-01-26 04:46:44 -0800</bug_when>
    <thetext>Any updates on this? A 6 year old bug report and a real blocker in my project. The only &quot;workaround&quot; is to disable authentication if Safari is supposed to be supported.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1412034</commentid>
    <comment_count>10</comment_count>
    <who name="Marc Herrmann">he</who>
    <bug_when>2018-04-05 04:36:52 -0700</bug_when>
    <thetext>This issue also leads to very high CPU load and energy consumption because of the high frequency of retry attempts for the websocket connection (with a simple javascript). Also, no workaround seems to be possible to prevent this behaviour.
So, are there still no plans to implement this? All other browsers / devices except Safari and/or iOS support this.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1467307</commentid>
    <comment_count>11</comment_count>
    <who name="Eugene">revanscript</who>
    <bug_when>2018-10-08 19:00:58 -0700</bug_when>
    <thetext>It&apos;s an important bug, why is it ignored for so long? 6 years</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1468083</commentid>
    <comment_count>12</comment_count>
    <who name="Jeremy Friesner">jaf</who>
    <bug_when>2018-10-11 11:02:03 -0700</bug_when>
    <thetext>This bug is also causing me trouble -- currently our only work-around is to tell our Mac users to download Chrome and use that instead, which is not a very popular response with them.  It would be really awesome if this could be fixed sooner rather than later!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1619049</commentid>
    <comment_count>13</comment_count>
    <who name="">andrewchen5678</who>
    <bug_when>2020-02-14 09:45:15 -0800</bug_when>
    <thetext>Any update on this? Yesterday I was testing with noVNC with http authentication and noticed this issue.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1620751</commentid>
    <comment_count>14</comment_count>
    <who name="Becky">becky</who>
    <bug_when>2020-02-19 11:19:31 -0800</bug_when>
    <thetext>This is still causing issues and excess work. We&apos;ve had to implement a whole new auth process for a customer just so that their setup supports Safari. Not everyone uses basic auth but for those who do this is a real issue.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1692653</commentid>
    <comment_count>15</comment_count>
    <who name="James">james.x.anderson+bugzilla</who>
    <bug_when>2020-09-28 13:23:35 -0700</bug_when>
    <thetext>Still causing an issue with code that works just fine in Chrome (barring iOS Chrome which uses webkit) and Firefox</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1701986</commentid>
    <comment_count>16</comment_count>
    <who name="piota@mail.de">piota</who>
    <bug_when>2020-10-27 11:02:52 -0700</bug_when>
    <thetext>I use nginx as a reverse proxy with https and want to access a dashboard. But this is with Safari Browser on iOS not possible. I get the error message: websocket not connected. On android devices or via desktop pc everything works fine. Please fix this important bug soon as possible. 

Thanks</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1873238</commentid>
    <comment_count>17</comment_count>
    <who name="">julian</who>
    <bug_when>2022-05-31 23:47:09 -0700</bug_when>
    <thetext>Is there any news on this 10 year old issue?  Any explanation as to why you wouldn&apos;t want to support this?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2187035</commentid>
    <comment_count>18</comment_count>
    <who name="Brent Fulgham">bfulgham</who>
    <bug_when>2026-03-04 11:13:01 -0800</bug_when>
    <thetext>The fix for this should have shipped in Safari on macOS 12 (Monterey) and iOS 15.0 back in the fall of 2021. The fix was in system networking dependencies, so may not have been visible to downlevel Safari releases to older operating systems.

Do you have a test case that shows the problem reproducing now in iOS 26/macOS 26? If so, please reopen this bug with further details.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2187109</commentid>
    <comment_count>19</comment_count>
    <who name="">andrewchen5678</who>
    <bug_when>2026-03-04 14:28:35 -0800</bug_when>
    <thetext>Just tested it and it is still not working on Safari only with MacOS 26 Tahoe. Can&apos;t believe this!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2187111</commentid>
    <comment_count>20</comment_count>
    <who name="">andrewchen5678</who>
    <bug_when>2026-03-04 14:31:37 -0800</bug_when>
    <thetext>Not working on iOS 26 either, please reopen!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2187163</commentid>
    <comment_count>21</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2026-03-04 16:41:05 -0800</bug_when>
    <thetext>Thank you for following up, reopening and creating a new internal copy.

It would be helpful have a test case though, as there are many subtleties in authentication, and we may try to test a slightly different case than what you did. In particular, was it specifically ws://username:password, as mentioned in one of the comments?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2187164</commentid>
    <comment_count>22</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2026-03-04 16:41:14 -0800</bug_when>
    <thetext>&lt;rdar://problem/171761514&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2187165</commentid>
    <comment_count>23</comment_count>
    <who name="">andrewchen5678</who>
    <bug_when>2026-03-04 16:43:14 -0800</bug_when>
    <thetext>I used caddy to enforce sitewide http basic auth, which like always, all browsers like chrome, firefox, etc. works except safari</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>