<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -88,48 +88,49 @@ static ngx_int_t ngx_http_accept_language_variable(ngx_http_request_t *r, ngx_ht
   u_char            *start, *pos, *end;
   ngx_array_t       *langs_array = (ngx_array_t *) data;
   ngx_str_t         *langs = (ngx_str_t *) langs_array-&gt;elts;  
-    
-  start = r-&gt;headers_in.accept_language-&gt;value.data;
-  end = start + r-&gt;headers_in.accept_language-&gt;value.len;
 
-  while (start &lt; end) {
-    // eating spaces
-    while (start &lt; end &amp;&amp; *start == ' ') {start++; }
+  if ( NULL != r-&gt;headers_in.accept_language ) {       
+    start = r-&gt;headers_in.accept_language-&gt;value.data;
+    end = start + r-&gt;headers_in.accept_language-&gt;value.len;
+
+    while (start &lt; end) {
+      // eating spaces
+      while (start &lt; end &amp;&amp; *start == ' ') {start++; }
       
-    pos = start;
+      pos = start;
     
-    while (pos &lt; end &amp;&amp; *pos != ',' &amp;&amp; *pos != ';') { pos++; }
+      while (pos &lt; end &amp;&amp; *pos != ',' &amp;&amp; *pos != ';') { pos++; }
     
-    for (i = 0; i &lt; langs_array-&gt;nelts; i++)
-    {      
-      if ((ngx_uint_t)(pos - start) &gt;= langs[i].len &amp;&amp; ngx_strncasecmp(start, langs[i].data, langs[i].len) == 0) {
-        found = 1;
-        break;
+      for (i = 0; i &lt; langs_array-&gt;nelts; i++)
+      {      
+        if ((ngx_uint_t)(pos - start) &gt;= langs[i].len &amp;&amp; ngx_strncasecmp(start, langs[i].data, langs[i].len) == 0) {
+          found = 1;
+          break;
+        }
       }
-    }
-    if (found)
-      break;
+      if (found)
+        break;
       
-    i = 0; // If not found default to the first language from the list
+      i = 0; // If not found default to the first language from the list
     
-    // We discard the quality value
-    if (*pos == ';') {
-      while (pos &lt; end &amp;&amp; *pos != ',') {pos++; }
-    }
-    if (*pos == ',') {
-      pos++;
-    }
+      // We discard the quality value
+      if (*pos == ';') {
+        while (pos &lt; end &amp;&amp; *pos != ',') {pos++; }
+      }
+      if (*pos == ',') {
+        pos++;
+      }
       
-    start = pos;
+      start = pos;
+    }
   }
 
-
   v-&gt;data = langs[i].data;
   v-&gt;len  = langs[i].len;
-  
+
   /* Set all required params */
   v-&gt;valid = 1;
   v-&gt;no_cacheable = 0;
   v-&gt;not_found = 0;
   return NGX_OK; 
-}
\ No newline at end of file
+}</diff>
      <filename>src/ngx_http_accept_language_module.c</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>8da19c746949a4ac5ec9b459dcbd2f53a44b1b7f</id>
    </parent>
  </parents>
  <author>
    <name>Guillaume Maury</name>
    <email>pm@gom-jabbar.org</email>
  </author>
  <url>http://github.com/giom/nginx_accept_language_module/commit/06b66da2fcd75f3e2f17f6b0af8f3525244968ea</url>
  <id>06b66da2fcd75f3e2f17f6b0af8f3525244968ea</id>
  <committed-date>2008-12-05T09:33:31-08:00</committed-date>
  <authored-date>2008-12-05T09:33:31-08:00</authored-date>
  <message>Fixed a bug where having a nil Accept-Language header would interupt the execution of the set_from_accept_language directive (I'm a bit ashamed at letting this bug through...)

Thanks goes to Paulo Almeida (pma) for finding this bug and sending me the patch</message>
  <tree>640fdfcaa04b358fa0c687fb35a82ca3f8f9a595</tree>
  <committer>
    <name>Guillaume Maury</name>
    <email>pm@gom-jabbar.org</email>
  </committer>
</commit>
