~ubuntu-branches/ubuntu/oneiric/ocsigen/oneiric

« back to all changes in this revision

Viewing changes to http/ocsigen_http_com.ml

  • Committer: Bazaar Package Importer
  • Author(s): Stephane Glondu
  • Date: 2009-07-02 10:02:08 UTC
  • mfrom: (1.1.9 upstream) (4.1.3 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090702100208-n158b1sqwzn0asil
Tags: 1.2.0-2
Fix build on non-native architectures

Show diffs side-by-side

added added

removed removed

Lines of Context:
676
676
let rec write_stream_raw out_ch stream =
677
677
  Ocsigen_stream.next stream >>= fun e ->
678
678
  match e with
679
 
    Ocsigen_stream.Finished _ ->
680
 
      Lwt.return ()
681
 
  | Ocsigen_stream.Cont (s, next) ->
682
 
      Lwt_chan.output_string out_ch s >>= fun () ->
683
 
      write_stream_raw out_ch next
 
679
    | Ocsigen_stream.Finished _ ->
 
680
        Lwt.return ()
 
681
    | Ocsigen_stream.Cont (s, next) ->
 
682
        Lwt_chan.output_string out_ch s >>= fun () ->
 
683
        write_stream_raw out_ch next
684
684
 
685
685
(*XXX We should check the length of the stream:
686
686
  - do not send more than expected
838
838
           Lwt.return ()
839
839
         end else begin
840
840
           Ocsigen_messages.debug2 "writing body";
841
 
           write_stream ~chunked out_ch res.res_stream
 
841
           write_stream ~chunked out_ch (fst res.res_stream)
842
842
         end) >>= fun () ->
843
843
         Lwt_chan.flush out_ch (* Vincent: I add this otherwise HEAD answers
844
844
                                  are not flushed by the reverse proxy *)
845
845
             >>= fun () ->
846
 
         Ocsigen_stream.finalize res.res_stream
 
846
         Ocsigen_stream.finalize (fst res.res_stream)
847
847
      )
848
848
      (fun e ->
849
849
        res.res_stop_stream () >>= fun () ->
850
 
        Ocsigen_stream.finalize res.res_stream >>= fun () ->
 
850
        Ocsigen_stream.finalize (fst res.res_stream) >>= fun () ->
851
851
        Lwt.fail e
852
852
      )
853
853
 
873
873
  in
874
874
  let mkcook path exp name c secure =
875
875
    Format.sprintf "%s=%s%s%s" name c
876
 
      ("; path=/" ^ Ocsigen_lib.string_of_url_path path)
 
876
(*VVV encode = true? *)
 
877
      ("; path=/" ^ Ocsigen_lib.string_of_url_path ~encode:true path)
877
878
      (if secure && slot.sl_ssl then "; secure" else "")^
878
879
      (match exp with
879
880
      | Some s -> "; expires=" ^
909
910
     match res.res_content_type with
910
911
     | None   -> None
911
912
     | Some s ->
912
 
         match String.sub s 0 4, res.res_charset with
913
 
         | "text", Some c -> Some (Format.sprintf "%s; charset=%s" s c)
914
 
         | _              -> res.res_content_type)
 
913
         if String.length s >= 4 then
 
914
           match String.sub s 0 4, res.res_charset with
 
915
             | "text", Some "" -> Some s
 
916
             | "text", Some c -> Some (Format.sprintf "%s; charset=%s" s c)
 
917
             | _              -> res.res_content_type
 
918
         else
 
919
           res.res_content_type
 
920
    )
915
921
  in
916
922
  let mode =
917
923
    match mode with