Class: Sketchup::Http::Request
| Relationships | |
| Inherits: | Object | 
Overview
Request objects allows you to send HTTP request to HTTP servers.
Class Method Summary
- 
    
      .new(url, method = Sketchup::Http::GET)  ⇒ Sketchup::Http::Request 
    
    constructor
    The default port is 80, to use a different port define it in the URL when creating a new Request.
Instance Attribute Summary
- 
    
      #body  ⇒ String 
    
    rw
    Gets the HTTP body that is going to be used when sending the request. 
- 
    
      #body=(body)  ⇒ String 
    
    rw
    Sets the HTTP body that is going to be used when sending the request. 
- 
    
      #headers  ⇒ Hash 
    
    rw
    Returns the HTTP headers that are going to be used when sending the request. 
- 
    
      #headers=(headers)  ⇒ Boolean 
    
    rw
    Sets the HTTP headers that are going to be used when sending the request. 
- 
    
      #method  ⇒ String 
    
    rw
    Returns the HTTP method that is going to be used when sending the request. 
- 
    
      #method=(method)  ⇒ Boolean 
    
    rw
    Sets the HTTP method that is going to be used when sending the request. 
Instance Method Summary
- 
    
      #cancel  ⇒ true 
    
    Cancels the request. 
- 
    
      #set_download_progress_callback {|current, total| ... } ⇒ Boolean 
    
    Adds a download progress callback block that will get called everytime we have received data from the server until the download finishes. 
- 
    
      #set_upload_progress_callback {|current, total| ... } ⇒ Boolean 
    
    Adds a upload progress callback block that will get called everytime we have uploaded data to the server until the upload finishes. 
- 
    
      #start {|request, response| ... } ⇒ Boolean 
    
    Starts the request with optionally a response callback block. 
- 
    
      #status  ⇒ Integer 
    
    Returns the internal status code. 
- 
    
      #url  ⇒ String 
    
    Returns a copy of the Request’s URL. 
Constructor Details
    .new(url, method = Sketchup::Http::GET)  ⇒ Request 
  
If no reference is kept to the Request, it can be garbage collected, making the download silently fail. This is especially noticeable for larger downloads that takes longer time.
The default port is 80, to use a different port define it in the URL when creating a new Request.
The method parameter accepts any custom HTTP method or one of the following:
- 
Sketchup::Http::GET
- 
Sketchup::Http::POST
- 
Sketchup::Http::PUT
- 
Sketchup::Http::DELETE
- 
Sketchup::Http::HEAD
- 
Sketchup::Http::OPTIONS
Instance Attribute Details
#body ⇒ String (rw)
Gets the HTTP body that is going to be used when sending the request.
#body=(body) ⇒ String (rw)
Sets the HTTP body that is going to be used when sending the request.
    #headers  ⇒ Hash  (rw)
  
Returns the HTTP headers that are going to be used when sending the request.
    #headers=(headers)  ⇒ Boolean  (rw)
  
Sets the HTTP headers that are going to be used when sending the request.
#method ⇒ String (rw)
Returns the HTTP method that is going to be used when sending the request.
    #method=(method)  ⇒ Boolean  (rw)
  
Sets the HTTP method that is going to be used when sending the request. The value can be any custom HTTP method or one of the following:
- 
Sketchup::Http::GET
- 
Sketchup::Http::POST
- 
Sketchup::Http::PUT
- 
Sketchup::Http::DELETE
- 
Sketchup::Http::HEAD
- 
Sketchup::Http::OPTIONS
Instance Method Details
    #cancel  ⇒ true 
  
Cancels the request.
    #set_download_progress_callback {|current, total| ... } ⇒ Boolean 
  
total is -1 if the server doesn’t specify a file size in the response header.
Adds a download progress callback block that will get called everytime we have received data from the server until the download finishes.
    #set_upload_progress_callback {|current, total| ... } ⇒ Boolean 
  
Adds a upload progress callback block that will get called everytime we have uploaded data to the server until the upload finishes.
    #start {|request, response| ... } ⇒ Boolean 
  
Starts the request with optionally a response callback block.
    #status  ⇒ Integer 
  
Returns the internal status code. It can be one of the following:
- 
Sketchup::Http::STATUS_UNKNOWN
- 
Sketchup::Http::STATUS_SUCCESS
- 
Sketchup::Http::STATUS_PENDING
- 
Sketchup::Http::STATUS_CANCELED
- 
Sketchup::Http::STATUS_FAILED
#url ⇒ String
Returns a copy of the Request’s URL.